Skip to content

Commit 2c6776c

Browse files
committed
Change lua_pushnumber to lua_pushinteger for non floating point values
1 parent 3d7c2fe commit 2c6776c

File tree

11 files changed

+316
-316
lines changed

11 files changed

+316
-316
lines changed

src/chat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ bool ChatChannel::executeOnSpeakEvent(const Player& player, SpeakClasses& type,
229229
tfs::lua::pushUserdata(L, &player);
230230
tfs::lua::setMetatable(L, -1, "Player");
231231

232-
lua_pushnumber(L, type);
232+
lua_pushinteger(L, type);
233233
tfs::lua::pushString(L, message);
234234

235235
bool result = false;

src/combat.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,8 @@ void ValueCallback::getMinMaxValues(Player* player, CombatDamage& damage) const
10791079
switch (type) {
10801080
case COMBAT_FORMULA_LEVELMAGIC: {
10811081
// onGetPlayerMinMaxValues(player, level, maglevel)
1082-
lua_pushnumber(L, player->getLevel());
1083-
lua_pushnumber(L, player->getMagicLevel() + player->getSpecialMagicLevel(damage.primary.type));
1082+
lua_pushinteger(L, player->getLevel());
1083+
lua_pushinteger(L, player->getMagicLevel() + player->getSpecialMagicLevel(damage.primary.type));
10841084
parameters += 2;
10851085
break;
10861086
}
@@ -1105,8 +1105,8 @@ void ValueCallback::getMinMaxValues(Player* player, CombatDamage& damage) const
11051105
damage.secondary.value = weapon->getElementDamage(player, nullptr, tool);
11061106
}
11071107

1108-
lua_pushnumber(L, player->getWeaponSkill(item ? item : tool));
1109-
lua_pushnumber(L, attackValue);
1108+
lua_pushinteger(L, player->getWeaponSkill(item ? item : tool));
1109+
lua_pushinteger(L, attackValue);
11101110
lua_pushnumber(L, player->getAttackFactor());
11111111
parameters += 3;
11121112
break;

src/creatureevent.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ bool CreatureEvent::executeOnThink(Creature* creature, uint32_t interval)
312312
scriptInterface->pushFunction(scriptId);
313313
tfs::lua::pushUserdata(L, creature);
314314
tfs::lua::setCreatureMetatable(L, -1, creature);
315-
lua_pushnumber(L, interval);
315+
lua_pushinteger(L, interval);
316316

317317
return scriptInterface->callFunction(2);
318318
}
@@ -401,9 +401,9 @@ bool CreatureEvent::executeAdvance(Player* player, skills_t skill, uint32_t oldL
401401
scriptInterface->pushFunction(scriptId);
402402
tfs::lua::pushUserdata(L, player);
403403
tfs::lua::setMetatable(L, -1, "Player");
404-
lua_pushnumber(L, static_cast<uint32_t>(skill));
405-
lua_pushnumber(L, oldLevel);
406-
lua_pushnumber(L, newLevel);
404+
lua_pushinteger(L, static_cast<uint32_t>(skill));
405+
lua_pushinteger(L, oldLevel);
406+
lua_pushinteger(L, newLevel);
407407

408408
return scriptInterface->callFunction(4);
409409
}
@@ -446,9 +446,9 @@ void CreatureEvent::executeModalWindow(Player* player, uint32_t modalWindowId, u
446446
tfs::lua::pushUserdata(L, player);
447447
tfs::lua::setMetatable(L, -1, "Player");
448448

449-
lua_pushnumber(L, modalWindowId);
450-
lua_pushnumber(L, buttonId);
451-
lua_pushnumber(L, choiceId);
449+
lua_pushinteger(L, modalWindowId);
450+
lua_pushinteger(L, buttonId);
451+
lua_pushinteger(L, choiceId);
452452

453453
scriptInterface->callVoidFunction(4);
454454
}
@@ -590,7 +590,7 @@ void CreatureEvent::executeExtendedOpcode(Player* player, uint8_t opcode, const
590590
tfs::lua::pushUserdata(L, player);
591591
tfs::lua::setMetatable(L, -1, "Player");
592592

593-
lua_pushnumber(L, opcode);
593+
lua_pushinteger(L, opcode);
594594
tfs::lua::pushString(L, buffer);
595595

596596
scriptInterface->callVoidFunction(3);

src/events.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ void Events::eventCreatureOnHear(Creature* creature, Creature* speaker, const st
306306
tfs::lua::setCreatureMetatable(L, -1, speaker);
307307

308308
tfs::lua::pushString(L, words);
309-
lua_pushnumber(L, type);
309+
lua_pushinteger(L, type);
310310

311311
scriptInterface.callVoidFunction(4);
312312
}
@@ -332,8 +332,8 @@ void Events::eventCreatureOnChangeZone(Creature* creature, ZoneType_t fromZone,
332332
tfs::lua::pushUserdata(L, creature);
333333
tfs::lua::setCreatureMetatable(L, -1, creature);
334334

335-
lua_pushnumber(L, fromZone);
336-
lua_pushnumber(L, toZone);
335+
lua_pushinteger(L, fromZone);
336+
lua_pushinteger(L, toZone);
337337

338338
scriptInterface.callVoidFunction(3);
339339
}
@@ -360,16 +360,16 @@ void Events::eventCreatureOnUpdateStorage(Creature* creature, uint32_t key, std:
360360
tfs::lua::pushUserdata(L, creature);
361361
tfs::lua::setMetatable(L, -1, "Creature");
362362

363-
lua_pushnumber(L, key);
363+
lua_pushinteger(L, key);
364364

365365
if (value) {
366-
lua_pushnumber(L, value.value());
366+
lua_pushinteger(L, value.value());
367367
} else {
368368
lua_pushnil(L);
369369
}
370370

371371
if (oldValue) {
372-
lua_pushnumber(L, oldValue.value());
372+
lua_pushinteger(L, oldValue.value());
373373
} else {
374374
lua_pushnil(L);
375375
}
@@ -560,7 +560,7 @@ void Events::eventPartyOnShareExperience(Party* party, uint64_t& exp)
560560
tfs::lua::pushUserdata(L, party);
561561
tfs::lua::setMetatable(L, -1, "Party");
562562

563-
lua_pushnumber(L, exp);
563+
lua_pushinteger(L, exp);
564564

565565
if (tfs::lua::protectedCall(L, 2, 1) != 0) {
566566
reportErrorFunc(L, tfs::lua::popString(L));
@@ -632,7 +632,7 @@ void Events::eventPlayerOnLook(Player* player, const Position& position, Thing*
632632
}
633633

634634
tfs::lua::pushPosition(L, position, stackpos);
635-
lua_pushnumber(L, lookDistance);
635+
lua_pushinteger(L, lookDistance);
636636

637637
scriptInterface.callVoidFunction(4);
638638
}
@@ -662,7 +662,7 @@ void Events::eventPlayerOnLookInBattleList(Player* player, Creature* creature, i
662662
tfs::lua::pushUserdata(L, creature);
663663
tfs::lua::setCreatureMetatable(L, -1, creature);
664664

665-
lua_pushnumber(L, lookDistance);
665+
lua_pushinteger(L, lookDistance);
666666

667667
scriptInterface.callVoidFunction(3);
668668
}
@@ -694,7 +694,7 @@ void Events::eventPlayerOnLookInTrade(Player* player, Player* partner, Item* ite
694694
tfs::lua::pushUserdata(L, item);
695695
tfs::lua::setItemMetatable(L, -1, item);
696696

697-
lua_pushnumber(L, lookDistance);
697+
lua_pushinteger(L, lookDistance);
698698

699699
scriptInterface.callVoidFunction(4);
700700
}
@@ -723,7 +723,7 @@ bool Events::eventPlayerOnLookInShop(Player* player, const ItemType* itemType, u
723723
tfs::lua::pushUserdata(L, itemType);
724724
tfs::lua::setMetatable(L, -1, "ItemType");
725725

726-
lua_pushnumber(L, count);
726+
lua_pushinteger(L, count);
727727

728728
return scriptInterface.callFunction(3);
729729
}
@@ -781,7 +781,7 @@ ReturnValue Events::eventPlayerOnMoveItem(Player* player, Item* item, uint16_t c
781781
tfs::lua::pushUserdata(L, item);
782782
tfs::lua::setItemMetatable(L, -1, item);
783783

784-
lua_pushnumber(L, count);
784+
lua_pushinteger(L, count);
785785
tfs::lua::pushPosition(L, fromPosition);
786786
tfs::lua::pushPosition(L, toPosition);
787787

@@ -827,7 +827,7 @@ void Events::eventPlayerOnItemMoved(Player* player, Item* item, uint16_t count,
827827
tfs::lua::pushUserdata(L, item);
828828
tfs::lua::setItemMetatable(L, -1, item);
829829

830-
lua_pushnumber(L, count);
830+
lua_pushinteger(L, count);
831831
tfs::lua::pushPosition(L, fromPosition);
832832
tfs::lua::pushPosition(L, toPosition);
833833

@@ -894,8 +894,8 @@ void Events::eventPlayerOnReportRuleViolation(Player* player, const std::string&
894894

895895
tfs::lua::pushString(L, targetName);
896896

897-
lua_pushnumber(L, reportType);
898-
lua_pushnumber(L, reportReason);
897+
lua_pushinteger(L, reportType);
898+
lua_pushinteger(L, reportReason);
899899

900900
tfs::lua::pushString(L, comment);
901901
tfs::lua::pushString(L, translation);
@@ -927,7 +927,7 @@ bool Events::eventPlayerOnReportBug(Player* player, const std::string& message,
927927

928928
tfs::lua::pushString(L, message);
929929
tfs::lua::pushPosition(L, position);
930-
lua_pushnumber(L, category);
930+
lua_pushinteger(L, category);
931931

932932
return scriptInterface.callFunction(4);
933933
}
@@ -980,7 +980,7 @@ bool Events::eventPlayerOnTurn(Player* player, Direction direction)
980980
tfs::lua::pushUserdata(L, player);
981981
tfs::lua::setMetatable(L, -1, "Player");
982982

983-
lua_pushnumber(L, direction);
983+
lua_pushinteger(L, direction);
984984

985985
return scriptInterface.callFunction(2);
986986
}
@@ -1138,7 +1138,7 @@ void Events::eventPlayerOnPodiumEdit(Player* player, Item* item, const Outfit_t&
11381138

11391139
tfs::lua::pushOutfit(L, outfit);
11401140

1141-
lua_pushnumber(L, direction);
1141+
lua_pushinteger(L, direction);
11421142
lua_pushboolean(L, podiumVisible);
11431143

11441144
scriptInterface.callFunction(5);
@@ -1173,8 +1173,8 @@ void Events::eventPlayerOnGainExperience(Player* player, Creature* source, uint6
11731173
lua_pushnil(L);
11741174
}
11751175

1176-
lua_pushnumber(L, exp);
1177-
lua_pushnumber(L, rawExp);
1176+
lua_pushinteger(L, exp);
1177+
lua_pushinteger(L, rawExp);
11781178
tfs::lua::pushBoolean(L, sendText);
11791179

11801180
if (tfs::lua::protectedCall(L, 5, 1) != 0) {
@@ -1208,7 +1208,7 @@ void Events::eventPlayerOnLoseExperience(Player* player, uint64_t& exp)
12081208
tfs::lua::pushUserdata(L, player);
12091209
tfs::lua::setMetatable(L, -1, "Player");
12101210

1211-
lua_pushnumber(L, exp);
1211+
lua_pushinteger(L, exp);
12121212

12131213
if (tfs::lua::protectedCall(L, 2, 1) != 0) {
12141214
reportErrorFunc(L, tfs::lua::popString(L));
@@ -1241,8 +1241,8 @@ void Events::eventPlayerOnGainSkillTries(Player* player, skills_t skill, uint64_
12411241
tfs::lua::pushUserdata(L, player);
12421242
tfs::lua::setMetatable(L, -1, "Player");
12431243

1244-
lua_pushnumber(L, skill);
1245-
lua_pushnumber(L, tries);
1244+
lua_pushinteger(L, skill);
1245+
lua_pushinteger(L, tries);
12461246

12471247
if (tfs::lua::protectedCall(L, 3, 1) != 0) {
12481248
reportErrorFunc(L, tfs::lua::popString(L));
@@ -1305,7 +1305,7 @@ void Events::eventPlayerOnInventoryUpdate(Player* player, Item* item, slots_t sl
13051305
tfs::lua::pushUserdata(L, item);
13061306
tfs::lua::setItemMetatable(L, -1, item);
13071307

1308-
lua_pushnumber(L, slot);
1308+
lua_pushinteger(L, slot);
13091309
tfs::lua::pushBoolean(L, equip);
13101310

13111311
scriptInterface.callVoidFunction(4);
@@ -1332,7 +1332,7 @@ void Events::eventPlayerOnNetworkMessage(Player* player, uint8_t recvByte, Netwo
13321332
tfs::lua::pushUserdata(L, player);
13331333
tfs::lua::setMetatable(L, -1, "Player");
13341334

1335-
lua_pushnumber(L, recvByte);
1335+
lua_pushinteger(L, recvByte);
13361336

13371337
tfs::lua::pushUserdata(L, msg);
13381338
tfs::lua::setMetatable(L, -1, "NetworkMessage");

src/globalevent.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ bool GlobalEvent::executeRecord(uint32_t current, uint32_t old)
340340
lua_State* L = scriptInterface->getLuaState();
341341
scriptInterface->pushFunction(scriptId);
342342

343-
lua_pushnumber(L, current);
344-
lua_pushnumber(L, old);
343+
lua_pushinteger(L, current);
344+
lua_pushinteger(L, old);
345345
return scriptInterface->callFunction(2);
346346
}
347347

@@ -359,7 +359,7 @@ bool GlobalEvent::executeEvent() const
359359

360360
int32_t params = 0;
361361
if (eventType == GLOBALEVENT_NONE || eventType == GLOBALEVENT_TIMER) {
362-
lua_pushnumber(L, interval);
362+
lua_pushinteger(L, interval);
363363
params = 1;
364364
}
365365

src/item.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class ItemAttributes
186186

187187
void operator()(bool v) const { tfs::lua::pushBoolean(L, v); }
188188

189-
void operator()(const int64_t& v) const { lua_pushnumber(L, v); }
189+
void operator()(const int64_t& v) const { lua_pushinteger(L, v); }
190190

191191
void operator()(const double& v) const { lua_pushnumber(L, v); }
192192
};

0 commit comments

Comments
 (0)