mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Don't check empty string for duplicate name
This commit is contained in:
parent
6e4b14588c
commit
a73f468ea4
2 changed files with 15 additions and 9 deletions
|
@ -810,7 +810,7 @@ static void readskincolor(MYFILE *f, INT32 num)
|
||||||
char truncword[namesize];
|
char truncword[namesize];
|
||||||
|
|
||||||
deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes
|
deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes
|
||||||
if (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || R_GetColorByName(truncword))
|
if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || R_GetColorByName(truncword)))
|
||||||
{
|
{
|
||||||
size_t lastchar = strlen(truncword);
|
size_t lastchar = strlen(truncword);
|
||||||
char oldword[lastchar+1];
|
char oldword[lastchar+1];
|
||||||
|
|
|
@ -1545,9 +1545,12 @@ static int lib_setSkinColor(lua_State *L)
|
||||||
if (strchr(info->name, ' ') != NULL)
|
if (strchr(info->name, ' ') != NULL)
|
||||||
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name);
|
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name);
|
||||||
|
|
||||||
UINT16 dupecheck = R_GetColorByName(info->name);
|
if (info->name[0] != '\0') // don't check empty string for dupe
|
||||||
if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors)))
|
{
|
||||||
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name);
|
UINT16 dupecheck = R_GetColorByName(info->name);
|
||||||
|
if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors)))
|
||||||
|
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name);
|
||||||
|
}
|
||||||
} else if (i == 2 || (str && fastcmp(str,"ramp"))) {
|
} else if (i == 2 || (str && fastcmp(str,"ramp"))) {
|
||||||
if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL)
|
if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL)
|
||||||
return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array.");
|
return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array.");
|
||||||
|
@ -1567,7 +1570,7 @@ static int lib_setSkinColor(lua_State *L)
|
||||||
else if (i == 5 || (str && fastcmp(str,"chatcolor")))
|
else if (i == 5 || (str && fastcmp(str,"chatcolor")))
|
||||||
info->chatcolor = (UINT16)luaL_checkinteger(L, 3);
|
info->chatcolor = (UINT16)luaL_checkinteger(L, 3);
|
||||||
else if (i == 6 || (str && fastcmp(str,"accessible")))
|
else if (i == 6 || (str && fastcmp(str,"accessible")))
|
||||||
info->accessible = lua_toboolean(L, 3) != 0;
|
info->accessible = lua_toboolean(L, 3);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1627,9 +1630,12 @@ static int skincolor_set(lua_State *L)
|
||||||
if (strchr(info->name, ' ') != NULL)
|
if (strchr(info->name, ' ') != NULL)
|
||||||
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name);
|
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name);
|
||||||
|
|
||||||
UINT16 dupecheck = R_GetColorByName(info->name);
|
if (info->name[0] != '\0') // don't check empty string for dupe
|
||||||
if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors)))
|
{
|
||||||
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name);
|
UINT16 dupecheck = R_GetColorByName(info->name);
|
||||||
|
if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors)))
|
||||||
|
CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name);
|
||||||
|
}
|
||||||
} else if (fastcmp(field,"ramp")) {
|
} else if (fastcmp(field,"ramp")) {
|
||||||
if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL)
|
if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL)
|
||||||
return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array.");
|
return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array.");
|
||||||
|
@ -1649,7 +1655,7 @@ static int skincolor_set(lua_State *L)
|
||||||
else if (fastcmp(field,"chatcolor"))
|
else if (fastcmp(field,"chatcolor"))
|
||||||
info->chatcolor = (UINT16)luaL_checkinteger(L, 3);
|
info->chatcolor = (UINT16)luaL_checkinteger(L, 3);
|
||||||
else if (fastcmp(field,"accessible"))
|
else if (fastcmp(field,"accessible"))
|
||||||
info->accessible = lua_toboolean(L, 3) != 0;
|
info->accessible = lua_toboolean(L, 3);
|
||||||
else
|
else
|
||||||
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field);
|
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue