diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index d2db7dbea..ff10a34c1 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1260,15 +1260,10 @@ extern int lib_hudadd(lua_State *L); static int lib_hudsetvotebackground(lua_State *L) { + memset(VoteScreen.luaPrefix, 0, sizeof(VoteScreen.luaPrefix)); + if (lua_isnoneornil(L, 1)) { - if (VoteScreen.luaVoteScreen) - { - free(VoteScreen.luaVoteScreen); - } - - VoteScreen.luaVoteScreen = NULL; - return 0; } @@ -1279,15 +1274,8 @@ static int lib_hudsetvotebackground(lua_State *L) return luaL_argerror(L, 1, "prefix should 4 characters wide"); } - if (!VoteScreen.luaVoteScreen) - { - VoteScreen.luaVoteScreen = (char*)malloc(5); - VoteScreen.luaVoteScreen[4] = 0; - } - - strncpy(VoteScreen.luaVoteScreen, prefix, 4); - - strupr(VoteScreen.luaVoteScreen); + strncpy(VoteScreen.luaPrefix, prefix, 4); + strupr(VoteScreen.luaPrefix); return 0; } diff --git a/src/y_inter.c b/src/y_inter.c index bec12d627..856ca3ac7 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -282,8 +282,8 @@ static void Y_VoteScreenCheck(void) { strcpy(VoteScreen.Prefix, "INTS"); - if (VoteScreen.luaVoteScreen) - strncpy(VoteScreen.Prefix, VoteScreen.luaVoteScreen, 4); + if (VoteScreen.luaPrefix[0] != 0) + strlcpy(VoteScreen.Prefix, VoteScreen.luaPrefix, sizeof(VoteScreen.Prefix)); else if (G_BattleGametype()) strcpy(VoteScreen.Prefix, "BTLS"); diff --git a/src/y_inter.h b/src/y_inter.h index eaed11397..4a665e5d9 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -62,7 +62,7 @@ extern intertype_t intertype; typedef struct { char Prefix[5]; // Race = INTSX, Battle = BTLSX - char *luaVoteScreen; // lua prefix + char luaPrefix[5]; // prefix for lua votescreens INT32 currentAnimFrame; // current animated background frame