mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-05 00:12:16 +00:00
Custom gametype constant support for Lua.
This commit is contained in:
parent
4ebbe4e518
commit
1edc72a3b8
1 changed files with 17 additions and 10 deletions
|
|
@ -2642,6 +2642,7 @@ static int lib_gAddGametype(lua_State *L)
|
||||||
lua_Integer i;
|
lua_Integer i;
|
||||||
|
|
||||||
const char *gtname = NULL;
|
const char *gtname = NULL;
|
||||||
|
const char *gtconst = NULL;
|
||||||
const char *gtdescription = NULL;
|
const char *gtdescription = NULL;
|
||||||
INT16 newgtidx = 0;
|
INT16 newgtidx = 0;
|
||||||
UINT32 newgtrules = 0;
|
UINT32 newgtrules = 0;
|
||||||
|
|
@ -2678,39 +2679,43 @@ static int lib_gAddGametype(lua_State *L)
|
||||||
if (!lua_isstring(L, 3))
|
if (!lua_isstring(L, 3))
|
||||||
TYPEERROR("name", LUA_TSTRING)
|
TYPEERROR("name", LUA_TSTRING)
|
||||||
gtname = Z_StrDup(lua_tostring(L, 3));
|
gtname = Z_StrDup(lua_tostring(L, 3));
|
||||||
} else if (i == 2 || (k && fasticmp(k, "rules"))) {
|
} else if (i == 2 || (k && fasticmp(k, "identifier"))) {
|
||||||
|
if (!lua_isstring(L, 3))
|
||||||
|
TYPEERROR("identifier", LUA_TSTRING)
|
||||||
|
gtconst = Z_StrDup(lua_tostring(L, 3));
|
||||||
|
} else if (i == 3 || (k && fasticmp(k, "rules"))) {
|
||||||
if (!lua_isnumber(L, 3))
|
if (!lua_isnumber(L, 3))
|
||||||
TYPEERROR("rules", LUA_TNUMBER)
|
TYPEERROR("rules", LUA_TNUMBER)
|
||||||
newgtrules = (UINT32)lua_tointeger(L, 3);
|
newgtrules = (UINT32)lua_tointeger(L, 3);
|
||||||
} else if (i == 3 || (k && fasticmp(k, "typeoflevel"))) {
|
} else if (i == 4 || (k && fasticmp(k, "typeoflevel"))) {
|
||||||
if (!lua_isnumber(L, 3))
|
if (!lua_isnumber(L, 3))
|
||||||
TYPEERROR("typeoflevel", LUA_TNUMBER)
|
TYPEERROR("typeoflevel", LUA_TNUMBER)
|
||||||
newgttol = (UINT32)lua_tointeger(L, 3);
|
newgttol = (UINT32)lua_tointeger(L, 3);
|
||||||
} else if (i == 4 || (k && fasticmp(k, "rankingtype"))) {
|
} else if (i == 5 || (k && fasticmp(k, "rankingtype"))) {
|
||||||
if (!lua_isnumber(L, 3))
|
if (!lua_isnumber(L, 3))
|
||||||
TYPEERROR("rankingtype", LUA_TNUMBER)
|
TYPEERROR("rankingtype", LUA_TNUMBER)
|
||||||
newgtrankingstype = (INT16)lua_tointeger(L, 3);
|
newgtrankingstype = (INT16)lua_tointeger(L, 3);
|
||||||
} else if (i == 5 || (k && fasticmp(k, "intermissiontype"))) {
|
} else if (i == 6 || (k && fasticmp(k, "intermissiontype"))) {
|
||||||
if (!lua_isnumber(L, 3))
|
if (!lua_isnumber(L, 3))
|
||||||
TYPEERROR("intermissiontype", LUA_TNUMBER)
|
TYPEERROR("intermissiontype", LUA_TNUMBER)
|
||||||
newgtinttype = (int)lua_tointeger(L, 3);
|
newgtinttype = (int)lua_tointeger(L, 3);
|
||||||
} else if (i == 6 || (k && fasticmp(k, "defaultpointlimit"))) {
|
} else if (i == 7 || (k && fasticmp(k, "defaultpointlimit"))) {
|
||||||
if (!lua_isnumber(L, 3))
|
if (!lua_isnumber(L, 3))
|
||||||
TYPEERROR("defaultpointlimit", LUA_TNUMBER)
|
TYPEERROR("defaultpointlimit", LUA_TNUMBER)
|
||||||
newgtpointlimit = (INT32)lua_tointeger(L, 3);
|
newgtpointlimit = (INT32)lua_tointeger(L, 3);
|
||||||
} else if (i == 7 || (k && fasticmp(k, "defaulttimelimit"))) {
|
} else if (i == 8 || (k && fasticmp(k, "defaulttimelimit"))) {
|
||||||
if (!lua_isnumber(L, 3))
|
if (!lua_isnumber(L, 3))
|
||||||
TYPEERROR("defaulttimelimit", LUA_TNUMBER)
|
TYPEERROR("defaulttimelimit", LUA_TNUMBER)
|
||||||
newgttimelimit = (INT32)lua_tointeger(L, 3);
|
newgttimelimit = (INT32)lua_tointeger(L, 3);
|
||||||
} else if (i == 8 || (k && fasticmp(k, "description"))) {
|
} else if (i == 9 || (k && fasticmp(k, "description"))) {
|
||||||
if (!lua_isstring(L, 3))
|
if (!lua_isstring(L, 3))
|
||||||
TYPEERROR("description", LUA_TSTRING)
|
TYPEERROR("description", LUA_TSTRING)
|
||||||
gtdescription = Z_StrDup(lua_tostring(L, 3));
|
gtdescription = Z_StrDup(lua_tostring(L, 3));
|
||||||
} else if (i == 9 || (k && fasticmp(k, "headerleftcolor"))) {
|
} else if (i == 10 || (k && fasticmp(k, "headerleftcolor"))) {
|
||||||
if (!lua_isnumber(L, 3))
|
if (!lua_isnumber(L, 3))
|
||||||
TYPEERROR("headerleftcolor", LUA_TNUMBER)
|
TYPEERROR("headerleftcolor", LUA_TNUMBER)
|
||||||
newgtleftcolor = (UINT8)lua_tointeger(L, 3);
|
newgtleftcolor = (UINT8)lua_tointeger(L, 3);
|
||||||
} else if (i == 10 || (k && fasticmp(k, "headerrightcolor"))) {
|
} else if (i == 11 || (k && fasticmp(k, "headerrightcolor"))) {
|
||||||
if (!lua_isnumber(L, 3))
|
if (!lua_isnumber(L, 3))
|
||||||
TYPEERROR("headerrightcolor", LUA_TNUMBER)
|
TYPEERROR("headerrightcolor", LUA_TNUMBER)
|
||||||
newgtrightcolor = (UINT8)lua_tointeger(L, 3);
|
newgtrightcolor = (UINT8)lua_tointeger(L, 3);
|
||||||
|
|
@ -2753,7 +2758,9 @@ static int lib_gAddGametype(lua_State *L)
|
||||||
Gametype_Names[newgtidx] = gtname;
|
Gametype_Names[newgtidx] = gtname;
|
||||||
|
|
||||||
// Write the constant name.
|
// Write the constant name.
|
||||||
G_AddGametypeConstant(newgtidx, gtname);
|
if (gtconst == NULL)
|
||||||
|
gtconst = gtname;
|
||||||
|
G_AddGametypeConstant(newgtidx, gtconst);
|
||||||
|
|
||||||
// Update gametype_cons_t accordingly.
|
// Update gametype_cons_t accordingly.
|
||||||
G_UpdateGametypeSelections();
|
G_UpdateGametypeSelections();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue