diff --git a/src/animation/animation.cpp b/src/animation/animation.cpp index 0fddcf990..ee37031eb 100644 --- a/src/animation/animation.cpp +++ b/src/animation/animation.cpp @@ -385,7 +385,7 @@ static const CAnimation *Advance(const CAnimation *anim, int n) /** ** Add a label */ -static void AddLabel(lua_State *, CAnimation *anim, const std::string &name) +static void AddLabel(CAnimation *anim, const std::string &name) { LabelsStruct label; @@ -482,7 +482,7 @@ static CAnimation *ParseAnimationFrame(lua_State *l, const char *str) anim = new CAnimation_Unbreakable; } else if (op1 == "label") { anim = new CAnimation_Label; - AddLabel(l, anim, extraArg); + AddLabel(anim, extraArg); } else if (op1 == "goto") { anim = new CAnimation_Goto; } else if (op1 == "random-goto") { diff --git a/src/animation/animation_ifvar.cpp b/src/animation/animation_ifvar.cpp index 92aff265f..254c8b9c9 100644 --- a/src/animation/animation_ifvar.cpp +++ b/src/animation/animation_ifvar.cpp @@ -49,13 +49,13 @@ enum EIfVarBinOp { IF_NOT_EQUAL, }; -bool binOpGreaterEqual(int lhs, int rhs) { return lhs >= rhs; } -bool binOpGreater(int lhs, int rhs) { return lhs > rhs; } -bool binOpLessEqual(int lhs, int rhs) { return lhs <= rhs; } -bool binOpLess(int lhs, int rhs) { return lhs < rhs; } -bool binOpEqual(int lhs, int rhs) { return lhs == rhs; } -bool binOpNotEqual(int lhs, int rhs) { return lhs != rhs; } -bool returnFalse(int , int) { return false; } +static bool binOpGreaterEqual(int lhs, int rhs) { return lhs >= rhs; } +static bool binOpGreater(int lhs, int rhs) { return lhs > rhs; } +static bool binOpLessEqual(int lhs, int rhs) { return lhs <= rhs; } +static bool binOpLess(int lhs, int rhs) { return lhs < rhs; } +static bool binOpEqual(int lhs, int rhs) { return lhs == rhs; } +static bool binOpNotEqual(int lhs, int rhs) { return lhs != rhs; } +static bool returnFalse(int, int) { return false; } /* virtual */ void CAnimation_IfVar::Action(CUnit &unit, int &/*move*/, int /*scale*/) const { diff --git a/src/editor/editloop.cpp b/src/editor/editloop.cpp index 797c1c240..f172917c7 100644 --- a/src/editor/editloop.cpp +++ b/src/editor/editloop.cpp @@ -1905,7 +1905,7 @@ void CEditor::Init() ShowLoadProgress("Script %s", buf); LuaLoadFile(buf); - CclGarbageCollect(0); // Cleanup memory after load + LuaGarbageCollect(); ThisPlayer = &Players[0]; diff --git a/src/game/game.cpp b/src/game/game.cpp index bd2525320..b55ca872c 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -370,11 +370,10 @@ static void WriteMapPreview(const char *mapname, CMap &map) // Write the map presentation file -static int WriteMapPresentation(const std::string &mapname, CMap &map, char *) +static int WriteMapPresentation(const std::string &mapname, CMap &map) { FileWriter *f = NULL; - // char *mapsetupname; const char *type[] = {"", "", "neutral", "nobody", "computer", "person", "rescue-passive", "rescue-active" }; @@ -532,7 +531,7 @@ int SaveStratagusMap(const std::string &mapName, CMap &map, int writeTerrain) WriteMapPreview(previewName, map); memcpy(setupExtension, ".sms", 4 * sizeof(char)); - if (WriteMapPresentation(mapName, map, mapSetup) == -1) { + if (WriteMapPresentation(mapName, map) == -1) { return -1; } diff --git a/src/game/loadgame.cpp b/src/game/loadgame.cpp index f8bcad9c6..a6d5c54c9 100644 --- a/src/game/loadgame.cpp +++ b/src/game/loadgame.cpp @@ -205,10 +205,10 @@ void LoadGame(const std::string &filename) SetDefaultTextColors(FontYellow, FontWhite); LoadFonts(); - CclGarbageCollect(0); + LuaGarbageCollect(); InitUnitTypes(1); LuaLoadFile(filename); - CclGarbageCollect(0); + LuaGarbageCollect(); PlaceUnits(); diff --git a/src/game/replay.cpp b/src/game/replay.cpp index 83afdb480..ea018ea8e 100644 --- a/src/game/replay.cpp +++ b/src/game/replay.cpp @@ -541,7 +541,7 @@ static int CclLog(lua_State *l) } else if (!strcmp(value, "Num")) { log->Num = LuaToNumber(l, -1); } else if (!strcmp(value, "SyncRandSeed")) { - log->SyncRandSeed = (unsigned)LuaToNumber(l, -1); + log->SyncRandSeed = LuaToUnsignedNumber(l, -1); } else { LuaError(l, "Unsupported key: %s" _C_ value); } diff --git a/src/include/net_message.h b/src/include/net_message.h index fd70f611e..7ebb3e952 100644 --- a/src/include/net_message.h +++ b/src/include/net_message.h @@ -53,8 +53,8 @@ class CNetworkHost { public: CNetworkHost() { Clear(); } - size_t Serialize(unsigned char *) const; - size_t Deserialize(const unsigned char *p); + size_t Serialize(unsigned char *buf) const; + size_t Deserialize(const unsigned char *buf); void Clear(); static size_t Size() { return 4 + 2 + 2 + NetPlayerNameSize; } diff --git a/src/include/script.h b/src/include/script.h index 98b41a6f9..3ae730080 100644 --- a/src/include/script.h +++ b/src/include/script.h @@ -286,7 +286,7 @@ extern int LuaToNumber(lua_State *l, int narg); extern unsigned int LuaToUnsignedNumber(lua_State *l, int narg); extern bool LuaToBoolean(lua_State *l, int narg); -extern void CclGarbageCollect(int fast); /// Perform garbage collection +extern void LuaGarbageCollect(); /// Perform garbage collection extern void InitLua(); /// Initialise Lua extern void LoadCcl(const std::string &filename); /// Load ccl config file extern void SavePreferences(); /// Save user preferences diff --git a/src/pathfinder/astar.cpp b/src/pathfinder/astar.cpp index 2582bae38..0c5375216 100644 --- a/src/pathfinder/astar.cpp +++ b/src/pathfinder/astar.cpp @@ -452,7 +452,7 @@ static inline int AStarAddNode(const Vec2i &pos, int o, int costs) ** Can be further optimised knowing that the new cost MUST BE LOWER ** than the old one. */ -static void AStarReplaceNode(int pos, int) +static void AStarReplaceNode(int pos) { ProfileBegin("AStarReplaceNode"); @@ -847,7 +847,7 @@ static int AStarSavePath(const Vec2i &startPos, const Vec2i &endPos, char *path, */ static int AStarFindSimplePath(const Vec2i &startPos, const Vec2i &goal, int gw, int gh, int, int, int minrange, int maxrange, - char *path, int, const CUnit &unit) + char *path, const CUnit &unit) { ProfileBegin("AStarFindSimplePath"); // At exact destination point already @@ -905,7 +905,7 @@ int AStarFindPath(const Vec2i &startPos, const Vec2i &goalPos, int gw, int gh, // Check for simple cases first int ret = AStarFindSimplePath(startPos, goalPos, gw, gh, tilesizex, tilesizey, - minrange, maxrange, path, pathlen, unit); + minrange, maxrange, path, unit); if (ret != PF_FAILED) { ProfileEnd("AStarFindPath"); return ret; @@ -1046,7 +1046,7 @@ int AStarFindPath(const Vec2i &startPos, const Vec2i &goalPos, int gw, int gh, } else { costToGoal = AStarCosts(endPos, goalPos); AStarMatrix[eo].CostToGoal = costToGoal; - AStarReplaceNode(j, AStarMatrix[eo].CostFromStart + costToGoal); + AStarReplaceNode(j); } // we don't have to add this point to the close set } diff --git a/src/stratagus/script.cpp b/src/stratagus/script.cpp index 0f52af0f3..6c3421b09 100644 --- a/src/stratagus/script.cpp +++ b/src/stratagus/script.cpp @@ -340,28 +340,18 @@ bool LuaToBoolean(lua_State *l, int narg) } /** -** Perform CCL garbage collection -** -** @param fast set this flag to disable slow GC (during game) +** Perform lua garbage collection */ -void CclGarbageCollect(int) +void LuaGarbageCollect() { #if LUA_VERSION_NUM >= 501 - DebugPrint("Garbage collect (before): %d\n" _C_ - lua_gc(Lua, LUA_GCCOUNT, 0)); - + DebugPrint("Garbage collect (before): %d\n" _C_ lua_gc(Lua, LUA_GCCOUNT, 0)); lua_gc(Lua, LUA_GCCOLLECT, 0); - - DebugPrint("Garbage collect (after): %d\n" _C_ - lua_gc(Lua, LUA_GCCOUNT, 0)); + DebugPrint("Garbage collect (after): %d\n" _C_ lua_gc(Lua, LUA_GCCOUNT, 0)); #else - DebugPrint("Garbage collect (before): %d/%d\n" _C_ - lua_getgccount(Lua) _C_ lua_getgcthreshold(Lua)); - + DebugPrint("Garbage collect (before): %d/%d\n" _C_ lua_getgccount(Lua) _C_ lua_getgcthreshold(Lua)); lua_setgcthreshold(Lua, 0); - - DebugPrint("Garbage collect (after): %d/%d\n" _C_ - lua_getgccount(Lua) _C_ lua_getgcthreshold(Lua)); + DebugPrint("Garbage collect (after): %d/%d\n" _C_ lua_getgccount(Lua) _C_ lua_getgcthreshold(Lua)); #endif } @@ -636,7 +626,7 @@ NumberDesc *CclParseNumberDesc(lua_State *l) } else if (!strcmp(key, "Loc")) { res->D.UnitStat.Loc = LuaToNumber(l, -1); if (res->D.UnitStat.Loc < 0 || 2 < res->D.UnitStat.Loc) { - LuaError(l, "Bad Loc number :'%d'" _C_(int) LuaToNumber(l, -1)); + LuaError(l, "Bad Loc number :'%d'" _C_ LuaToNumber(l, -1)); } } else { LuaError(l, "Bad param %s for Unit" _C_ key); @@ -2204,7 +2194,7 @@ void LoadCcl(const std::string &filename) ShowLoadProgress("Script %s\n", buf); LuaLoadFile(buf); CclInConfigFile = 0; - CclGarbageCollect(0); // Cleanup memory after load + LuaGarbageCollect(); } diff --git a/src/stratagus/script_player.cpp b/src/stratagus/script_player.cpp index c2c88f92a..18dd6d9b3 100644 --- a/src/stratagus/script_player.cpp +++ b/src/stratagus/script_player.cpp @@ -66,7 +66,7 @@ extern CUnit *CclGetUnitFromRef(lua_State *l); */ static CPlayer *CclGetPlayer(lua_State *l) { - return &Players[(int)LuaToNumber(l, -1)]; + return &Players[LuaToNumber(l, -1)]; } /** diff --git a/src/stratagus/stratagus.cpp b/src/stratagus/stratagus.cpp index 57d1eae1a..87f0b8203 100644 --- a/src/stratagus/stratagus.cpp +++ b/src/stratagus/stratagus.cpp @@ -609,7 +609,6 @@ int stratagusMain(int argc, char **argv) #ifdef REDIRECT_OUTPUT RedirectOutput(); #endif - #ifdef USE_BEOS // Parse arguments for BeOS beos_init(argc, argv); diff --git a/src/unit/script_unit.cpp b/src/unit/script_unit.cpp index 349d3e5ab..d9dac942a 100644 --- a/src/unit/script_unit.cpp +++ b/src/unit/script_unit.cpp @@ -125,7 +125,7 @@ static int CclResourcesMultiBuildersMultiplier(lua_State *l) */ static CUnit *CclGetUnit(lua_State *l) { - return &UnitManager.GetSlotUnit((int)LuaToNumber(l, -1)); + return &UnitManager.GetSlotUnit(LuaToNumber(l, -1)); } /** @@ -307,7 +307,7 @@ static int CclUnit(lua_State *l) lua_pop(l, 1); } else if (!strcmp(value, "player")) { lua_rawgeti(l, 2, j + 1); - player = &Players[(int)LuaToNumber(l, -1)]; + player = &Players[LuaToNumber(l, -1)]; lua_pop(l, 1); // During a unit's death animation (when action is "die" but the @@ -374,7 +374,7 @@ static int CclUnit(lua_State *l) lua_pop(l, 1); } else if (!strcmp(value, "stats")) { lua_rawgeti(l, 2, j + 1); - unit->Stats = &type->Stats[(int)LuaToNumber(l, -1)]; + unit->Stats = &type->Stats[LuaToNumber(l, -1)]; lua_pop(l, 1); } else if (!strcmp(value, "pixel")) { lua_rawgeti(l, 2, j + 1); @@ -425,7 +425,7 @@ static int CclUnit(lua_State *l) --j; } else if (!strcmp(value, "rescued-from")) { lua_rawgeti(l, 2, j + 1); - unit->RescuedFrom = &Players[(int)LuaToNumber(l, -1)]; + unit->RescuedFrom = &Players[LuaToNumber(l, -1)]; lua_pop(l, 1); } else if (!strcmp(value, "seen-by-player")) { lua_rawgeti(l, 2, j + 1);