Lua code improvements.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8727 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-01-09 12:19:56 +00:00
parent e35c52821f
commit 6386338422
+61 -63
View File
@@ -2336,86 +2336,84 @@ static int l_WhoIsThere2 (lua_State *L)
//set merc //set merc
static int l_SetMercProfiles(lua_State *L) static int l_SetMercProfiles(lua_State *L)
{ {
MERCPROFILESTRUCT * pProfile; MERCPROFILESTRUCT * pProfile;
UINT8 idNPC = -1; UINT8 idNPC;
UINT16 x = -1; UINT16 x = 0;
UINT16 y = -1; UINT16 y = 0;
UINT8 z = -1; UINT8 z = 255;
UINT32 Orders = -1; UINT32 Orders = -1;
UINT16 usEyesX = -1; UINT16 usEyesX = -1;
UINT16 usEyesY = -1; UINT16 usEyesY = -1;
UINT16 usMouthX = -1; UINT16 usMouthX = -1;
UINT16 usMouthY = -1; UINT16 usMouthY = -1;
UINT32 uiEyeDelay = -1; UINT32 uiEyeDelay = -1;
UINT32 uiMouthDelay = -1; UINT32 uiMouthDelay = -1;
UINT32 uiWeeklySalary = -1; UINT32 uiWeeklySalary = -1;
UINT32 uiBiWeeklySalary = -1; UINT32 uiBiWeeklySalary = -1;
INT16 sSalary = -1; INT16 sSalary = -1;
UINT8 ubBodyType = -1; UINT8 ubBodyType = -1;
idNPC = lh_getIntegerFromTable(L, "IDProfile"); idNPC = lh_getIntegerFromTable(L, "IDProfile");
if ( idNPC > -1 ) if (idNPC < NUM_PROFILES)
{ {
pProfile = &(gMercProfiles[ idNPC ]); pProfile = &(gMercProfiles[idNPC]);
x = lh_getIntegerFromTable(L, "SectorX"); x = lh_getIntegerFromTable(L, "SectorX");
y = lh_getIntegerFromTable(L, "SectorY"); y = lh_getIntegerFromTable(L, "SectorY");
z = lh_getIntegerFromTable(L, "SectorZ"); z = lh_getIntegerFromTable(L, "SectorZ");
usEyesX = lh_getIntegerFromTable(L, "EyesX"); usEyesX = lh_getIntegerFromTable(L, "EyesX");
usEyesY = lh_getIntegerFromTable(L, "EyesY"); usEyesY = lh_getIntegerFromTable(L, "EyesY");
usMouthX = lh_getIntegerFromTable(L, "MouthX"); usMouthX = lh_getIntegerFromTable(L, "MouthX");
usMouthY = lh_getIntegerFromTable(L, "MouthY"); usMouthY = lh_getIntegerFromTable(L, "MouthY");
uiEyeDelay = lh_getIntegerFromTable(L, "EyeDelay"); uiEyeDelay = lh_getIntegerFromTable(L, "EyeDelay");
uiMouthDelay = lh_getIntegerFromTable(L, "MouthDelay"); uiMouthDelay = lh_getIntegerFromTable(L, "MouthDelay");
uiWeeklySalary = lh_getIntegerFromTable(L, "WeeklySalary"); uiWeeklySalary = lh_getIntegerFromTable(L, "WeeklySalary");
uiBiWeeklySalary = lh_getIntegerFromTable(L, "BiWeeklySalary"); uiBiWeeklySalary = lh_getIntegerFromTable(L, "BiWeeklySalary");
sSalary = lh_getIntegerFromTable(L, "Salary"); sSalary = lh_getIntegerFromTable(L, "Salary");
ubBodyType = lh_getIntegerFromTable(L, "BodyType"); ubBodyType = lh_getIntegerFromTable(L, "BodyType");
if (x >= 1 && x <= 16)
pProfile->sSectorX = x;
if ((x != -1 )&& (x >= 1 || x <= 16) ) if (y >= 1 && y <= 16)
pProfile->sSectorX = x; pProfile->sSectorY = y;
if((y != -1) && (y >= 1 || y <= 16) ) if (z <= 3)
pProfile->sSectorY = y; pProfile->bSectorZ = z;
if ((z != -1) && (z >= 0 || z <= 3) ) if (usEyesX != -1)
pProfile->bSectorZ = z; pProfile->usEyesX = usEyesX;
if ( usEyesX != -1 ) if (usEyesY != -1)
pProfile->usEyesX = usEyesX; pProfile->usEyesY = usEyesY;
if ( usEyesY != -1 ) if (usMouthX != -1)
pProfile->usEyesY = usEyesY; pProfile->usMouthX = usMouthX;
if ( usMouthX != -1 ) if (usMouthY != -1)
pProfile->usMouthX = usMouthX; pProfile->usMouthY = usMouthY;
if ( usMouthY != -1 ) if (uiEyeDelay != -1)
pProfile->usMouthY = usMouthY; pProfile->uiEyeDelay = uiEyeDelay;
if ( uiEyeDelay != -1 ) if (uiMouthDelay != -1)
pProfile->uiEyeDelay = uiEyeDelay; pProfile->uiMouthDelay = uiMouthDelay;
if ( uiMouthDelay != -1 ) if (uiWeeklySalary != -1)
pProfile->uiMouthDelay = uiMouthDelay; pProfile->uiWeeklySalary = uiWeeklySalary;
if ( uiWeeklySalary != -1 ) if (uiBiWeeklySalary != -1)
pProfile->uiWeeklySalary = uiWeeklySalary; pProfile->uiBiWeeklySalary = uiBiWeeklySalary;
if ( uiBiWeeklySalary != -1 ) if (sSalary != -1)
pProfile->uiBiWeeklySalary = uiBiWeeklySalary; pProfile->sSalary = sSalary;
if ( sSalary != -1 )
pProfile->sSalary = sSalary;
if ( ubBodyType != -1 )
pProfile->ubBodyType = ubBodyType;
}
if (ubBodyType != -1)
pProfile->ubBodyType = ubBodyType;
}
return 0; return 0;
} }
@@ -6351,7 +6349,7 @@ static int l_ActivateSwitchInGridNo(lua_State *L)
UINT8 ubID = lua_tointeger(L, 1); UINT8 ubID = lua_tointeger(L, 1);
INT32 sGridNo = lua_tointeger(L, 2); INT32 sGridNo = lua_tointeger(L, 2);
if (!TileIsOutOfBounds(sGridNo) > 0 && ubID < TOTAL_SOLDIERS) if (!TileIsOutOfBounds(sGridNo) && ubID < TOTAL_SOLDIERS)
ActivateSwitchInGridNo(ubID, sGridNo); ActivateSwitchInGridNo(ubID, sGridNo);
} }