Clean up: Remove unused arg from some functions.
Remove some useless cast.
This commit is contained in:
parent
537acf8f38
commit
c9d9d1723e
13 changed files with 35 additions and 47 deletions
src
animation
editor
game
include
pathfinder
stratagus
unit
|
@ -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") {
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1905,7 +1905,7 @@ void CEditor::Init()
|
|||
|
||||
ShowLoadProgress("Script %s", buf);
|
||||
LuaLoadFile(buf);
|
||||
CclGarbageCollect(0); // Cleanup memory after load
|
||||
LuaGarbageCollect();
|
||||
|
||||
ThisPlayer = &Players[0];
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue