Make EventNames[] an array of (const char *) instead of const tokenlist.

git-svn-id: https://svn.eduke32.com/eduke32@3258 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-12-09 13:24:36 +00:00
parent 599d9232f1
commit 5c06ef08bf
4 changed files with 124 additions and 107 deletions

View file

@ -569,104 +569,104 @@ const char *keyw[] =
"<null>" "<null>"
}; };
// KEEPINSYNC2 // KEEPINSYNC with enum GameEvent_t and lunatic/con_lang.lua
const tokenlist EventNames[MAXEVENTS] = const char *EventNames[MAXEVENTS] =
{ {
{ "EVENT_INIT", EVENT_INIT }, "EVENT_INIT",
{ "EVENT_ENTERLEVEL", EVENT_ENTERLEVEL }, "EVENT_ENTERLEVEL",
{ "EVENT_RESETWEAPONS", EVENT_RESETWEAPONS }, "EVENT_RESETWEAPONS",
{ "EVENT_RESETINVENTORY", EVENT_RESETINVENTORY }, "EVENT_RESETINVENTORY",
{ "EVENT_HOLSTER", EVENT_HOLSTER }, "EVENT_HOLSTER",
{ "EVENT_LOOKLEFT", EVENT_LOOKLEFT }, "EVENT_LOOKLEFT",
{ "EVENT_LOOKRIGHT", EVENT_LOOKRIGHT }, "EVENT_LOOKRIGHT",
{ "EVENT_SOARUP", EVENT_SOARUP }, "EVENT_SOARUP",
{ "EVENT_SOARDOWN", EVENT_SOARDOWN }, "EVENT_SOARDOWN",
{ "EVENT_CROUCH", EVENT_CROUCH }, "EVENT_CROUCH",
{ "EVENT_JUMP", EVENT_JUMP }, "EVENT_JUMP",
{ "EVENT_RETURNTOCENTER", EVENT_RETURNTOCENTER }, "EVENT_RETURNTOCENTER",
{ "EVENT_LOOKUP", EVENT_LOOKUP }, "EVENT_LOOKUP",
{ "EVENT_LOOKDOWN", EVENT_LOOKDOWN }, "EVENT_LOOKDOWN",
{ "EVENT_AIMUP", EVENT_AIMUP }, "EVENT_AIMUP",
{ "EVENT_FIRE", EVENT_FIRE }, "EVENT_FIRE",
{ "EVENT_CHANGEWEAPON", EVENT_CHANGEWEAPON }, "EVENT_CHANGEWEAPON",
{ "EVENT_GETSHOTRANGE", EVENT_GETSHOTRANGE }, "EVENT_GETSHOTRANGE",
{ "EVENT_GETAUTOAIMANGLE", EVENT_GETAUTOAIMANGLE }, "EVENT_GETAUTOAIMANGLE",
{ "EVENT_GETLOADTILE", EVENT_GETLOADTILE }, "EVENT_GETLOADTILE",
{ "EVENT_CHEATGETSTEROIDS", EVENT_CHEATGETSTEROIDS }, "EVENT_CHEATGETSTEROIDS",
{ "EVENT_CHEATGETHEAT", EVENT_CHEATGETHEAT }, "EVENT_CHEATGETHEAT",
{ "EVENT_CHEATGETBOOT", EVENT_CHEATGETBOOT }, "EVENT_CHEATGETBOOT",
{ "EVENT_CHEATGETSHIELD", EVENT_CHEATGETSHIELD }, "EVENT_CHEATGETSHIELD",
{ "EVENT_CHEATGETSCUBA", EVENT_CHEATGETSCUBA }, "EVENT_CHEATGETSCUBA",
{ "EVENT_CHEATGETHOLODUKE", EVENT_CHEATGETHOLODUKE }, "EVENT_CHEATGETHOLODUKE",
{ "EVENT_CHEATGETJETPACK", EVENT_CHEATGETJETPACK }, "EVENT_CHEATGETJETPACK",
{ "EVENT_CHEATGETFIRSTAID", EVENT_CHEATGETFIRSTAID }, "EVENT_CHEATGETFIRSTAID",
{ "EVENT_QUICKKICK", EVENT_QUICKKICK }, "EVENT_QUICKKICK",
{ "EVENT_INVENTORY", EVENT_INVENTORY }, "EVENT_INVENTORY",
{ "EVENT_USENIGHTVISION", EVENT_USENIGHTVISION }, "EVENT_USENIGHTVISION",
{ "EVENT_USESTEROIDS", EVENT_USESTEROIDS }, "EVENT_USESTEROIDS",
{ "EVENT_INVENTORYLEFT", EVENT_INVENTORYLEFT }, "EVENT_INVENTORYLEFT",
{ "EVENT_INVENTORYRIGHT", EVENT_INVENTORYRIGHT }, "EVENT_INVENTORYRIGHT",
{ "EVENT_HOLODUKEON", EVENT_HOLODUKEON }, "EVENT_HOLODUKEON",
{ "EVENT_HOLODUKEOFF", EVENT_HOLODUKEOFF }, "EVENT_HOLODUKEOFF",
{ "EVENT_USEMEDKIT", EVENT_USEMEDKIT }, "EVENT_USEMEDKIT",
{ "EVENT_USEJETPACK", EVENT_USEJETPACK }, "EVENT_USEJETPACK",
{ "EVENT_TURNAROUND", EVENT_TURNAROUND }, "EVENT_TURNAROUND",
{ "EVENT_DISPLAYWEAPON", EVENT_DISPLAYWEAPON }, "EVENT_DISPLAYWEAPON",
{ "EVENT_FIREWEAPON", EVENT_FIREWEAPON }, "EVENT_FIREWEAPON",
{ "EVENT_SELECTWEAPON", EVENT_SELECTWEAPON }, "EVENT_SELECTWEAPON",
{ "EVENT_MOVEFORWARD", EVENT_MOVEFORWARD }, "EVENT_MOVEFORWARD",
{ "EVENT_MOVEBACKWARD", EVENT_MOVEBACKWARD }, "EVENT_MOVEBACKWARD",
{ "EVENT_TURNLEFT", EVENT_TURNLEFT }, "EVENT_TURNLEFT",
{ "EVENT_TURNRIGHT", EVENT_TURNRIGHT }, "EVENT_TURNRIGHT",
{ "EVENT_STRAFELEFT", EVENT_STRAFELEFT }, "EVENT_STRAFELEFT",
{ "EVENT_STRAFERIGHT", EVENT_STRAFERIGHT }, "EVENT_STRAFERIGHT",
{ "EVENT_WEAPKEY1", EVENT_WEAPKEY1 }, "EVENT_WEAPKEY1",
{ "EVENT_WEAPKEY2", EVENT_WEAPKEY2 }, "EVENT_WEAPKEY2",
{ "EVENT_WEAPKEY3", EVENT_WEAPKEY3 }, "EVENT_WEAPKEY3",
{ "EVENT_WEAPKEY4", EVENT_WEAPKEY4 }, "EVENT_WEAPKEY4",
{ "EVENT_WEAPKEY5", EVENT_WEAPKEY5 }, "EVENT_WEAPKEY5",
{ "EVENT_WEAPKEY6", EVENT_WEAPKEY6 }, "EVENT_WEAPKEY6",
{ "EVENT_WEAPKEY7", EVENT_WEAPKEY7 }, "EVENT_WEAPKEY7",
{ "EVENT_WEAPKEY8", EVENT_WEAPKEY8 }, "EVENT_WEAPKEY8",
{ "EVENT_WEAPKEY9", EVENT_WEAPKEY9 }, "EVENT_WEAPKEY9",
{ "EVENT_WEAPKEY10", EVENT_WEAPKEY10 }, "EVENT_WEAPKEY10",
{ "EVENT_DRAWWEAPON", EVENT_DRAWWEAPON }, "EVENT_DRAWWEAPON",
{ "EVENT_DISPLAYCROSSHAIR", EVENT_DISPLAYCROSSHAIR }, "EVENT_DISPLAYCROSSHAIR",
{ "EVENT_DISPLAYREST", EVENT_DISPLAYREST }, "EVENT_DISPLAYREST",
{ "EVENT_DISPLAYSBAR", EVENT_DISPLAYSBAR }, "EVENT_DISPLAYSBAR",
{ "EVENT_RESETPLAYER", EVENT_RESETPLAYER }, "EVENT_RESETPLAYER",
{ "EVENT_INCURDAMAGE", EVENT_INCURDAMAGE }, "EVENT_INCURDAMAGE",
{ "EVENT_AIMDOWN", EVENT_AIMDOWN }, "EVENT_AIMDOWN",
{ "EVENT_GAME", EVENT_GAME }, "EVENT_GAME",
{ "EVENT_PREVIOUSWEAPON", EVENT_PREVIOUSWEAPON }, "EVENT_PREVIOUSWEAPON",
{ "EVENT_NEXTWEAPON", EVENT_NEXTWEAPON }, "EVENT_NEXTWEAPON",
{ "EVENT_SWIMUP", EVENT_SWIMUP }, "EVENT_SWIMUP",
{ "EVENT_SWIMDOWN", EVENT_SWIMDOWN }, "EVENT_SWIMDOWN",
{ "EVENT_GETMENUTILE", EVENT_GETMENUTILE }, "EVENT_GETMENUTILE",
{ "EVENT_SPAWN", EVENT_SPAWN }, "EVENT_SPAWN",
{ "EVENT_LOGO", EVENT_LOGO }, "EVENT_LOGO",
{ "EVENT_EGS", EVENT_EGS }, "EVENT_EGS",
{ "EVENT_DOFIRE", EVENT_DOFIRE }, "EVENT_DOFIRE",
{ "EVENT_PRESSEDFIRE", EVENT_PRESSEDFIRE }, "EVENT_PRESSEDFIRE",
{ "EVENT_USE", EVENT_USE }, "EVENT_USE",
{ "EVENT_PROCESSINPUT", EVENT_PROCESSINPUT }, "EVENT_PROCESSINPUT",
{ "EVENT_FAKEDOMOVETHINGS", EVENT_FAKEDOMOVETHINGS }, "EVENT_FAKEDOMOVETHINGS",
{ "EVENT_DISPLAYROOMS", EVENT_DISPLAYROOMS }, "EVENT_DISPLAYROOMS",
{ "EVENT_KILLIT", EVENT_KILLIT }, "EVENT_KILLIT",
{ "EVENT_LOADACTOR", EVENT_LOADACTOR }, "EVENT_LOADACTOR",
{ "EVENT_DISPLAYBONUSSCREEN", EVENT_DISPLAYBONUSSCREEN }, "EVENT_DISPLAYBONUSSCREEN",
{ "EVENT_DISPLAYMENU", EVENT_DISPLAYMENU }, "EVENT_DISPLAYMENU",
{ "EVENT_DISPLAYMENUREST", EVENT_DISPLAYMENUREST }, "EVENT_DISPLAYMENUREST",
{ "EVENT_DISPLAYLOADINGSCREEN", EVENT_DISPLAYLOADINGSCREEN }, "EVENT_DISPLAYLOADINGSCREEN",
{ "EVENT_ANIMATESPRITES", EVENT_ANIMATESPRITES }, "EVENT_ANIMATESPRITES",
{ "EVENT_NEWGAME", EVENT_NEWGAME }, "EVENT_NEWGAME",
{ "EVENT_SOUND", EVENT_SOUND }, "EVENT_SOUND",
{ "EVENT_CHECKTOUCHDAMAGE", EVENT_CHECKTOUCHDAMAGE }, "EVENT_CHECKTOUCHDAMAGE",
{ "EVENT_CHECKFLOORDAMAGE", EVENT_CHECKFLOORDAMAGE }, "EVENT_CHECKFLOORDAMAGE",
{ "EVENT_LOADGAME", EVENT_LOADGAME }, "EVENT_LOADGAME",
{ "EVENT_SAVEGAME", EVENT_SAVEGAME }, "EVENT_SAVEGAME",
{ "EVENT_PREGAME", EVENT_PREGAME }, "EVENT_PREGAME",
{ "EVENT_CHANGEMENU", EVENT_CHANGEMENU } "EVENT_CHANGEMENU"
}; };
const memberlabel_t SectorLabels[]= const memberlabel_t SectorLabels[]=
@ -5713,7 +5713,7 @@ static void C_AddDefaultDefinitions(void)
int32_t i; int32_t i;
for (i=0; i<MAXEVENTS; i++) for (i=0; i<MAXEVENTS; i++)
C_AddDefinition(EventNames[i].text, EventNames[i].tokenid, LABEL_DEFINE); C_AddDefinition(EventNames[i], i, LABEL_DEFINE);
for (i=0; i<NUMGAMEFUNCTIONS; i++) for (i=0; i<NUMGAMEFUNCTIONS; i++)
{ {

View file

@ -86,7 +86,7 @@ typedef struct
int32_t maxParm2; int32_t maxParm2;
} memberlabel_t; } memberlabel_t;
extern const tokenlist EventNames[]; // MAXEVENTS extern const char *EventNames[]; // MAXEVENTS
extern const memberlabel_t SectorLabels[]; extern const memberlabel_t SectorLabels[];
extern const memberlabel_t WallLabels[]; extern const memberlabel_t WallLabels[];
extern const memberlabel_t ActorLabels[]; extern const memberlabel_t ActorLabels[];

View file

@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "gamedef.h" // vmstate_t #include "gamedef.h" // vmstate_t
// the order of these can't be changed or else compatibility with EDuke 2.0 mods will break // the order of these can't be changed or else compatibility with EDuke 2.0 mods will break
// KEEPINSYNC2 with EventNames[] and lunatic/con_lang.lua // KEEPINSYNC with EventNames[] and lunatic/con_lang.lua
enum GameEvent_t { enum GameEvent_t {
EVENT_INIT, // 0 EVENT_INIT, // 0
EVENT_ENTERLEVEL, EVENT_ENTERLEVEL,

View file

@ -64,18 +64,35 @@ double rand_jkiss_dbl(rng_jkiss_t *s)
void El_PrintTimes(void) void El_PrintTimes(void)
{ {
int32_t i; int32_t i, maxlen=0;
char buf[32];
const char nn = Bstrlen("EVENT_");
for (i=0; i<MAXEVENTS; i++)
{
int32_t len = Bstrlen(EventNames[i]+nn);
Bassert(len < (int32_t)sizeof(buf));
maxlen = max(len, maxlen);
}
OSD_Printf("{\n {\n"); OSD_Printf("{\n {\n");
OSD_Printf(" -- event times, [event]={ total calls, total time in ms, time per call in us }\n"); OSD_Printf(" -- event times, [event]={ total calls, total time [ms], mean time/call [us] }\n");
for (i=0; i<MAXEVENTS; i++) for (i=0; i<MAXEVENTS; i++)
if (g_eventCalls[i]) if (g_eventCalls[i])
OSD_Printf(" [%2d]={ %8d, %9.3f, %9.3f },\n", {
i, g_eventCalls[i], g_eventTotalMs[i], int32_t n=Bsprintf(buf, "%s", EventNames[i]+nn);
for (; n<maxlen; n++)
buf[n] = ' ';
buf[maxlen] = 0;
OSD_Printf(" [%s]={ %8d, %9.3f, %9.3f },\n",
buf, g_eventCalls[i], g_eventTotalMs[i],
1000*g_eventTotalMs[i]/g_eventCalls[i]); 1000*g_eventTotalMs[i]/g_eventCalls[i]);
}
OSD_Printf(" },\n\n {\n"); OSD_Printf(" },\n\n {\n");
OSD_Printf(" -- actor times, [tile]={ total calls, total time in ms, time per call in us }\n"); OSD_Printf(" -- actor times, [tile]={ total calls, total time [ms], mean time/call [us] }\n");
for (i=0; i<MAXTILES; i++) for (i=0; i<MAXTILES; i++)
if (g_actorCalls[i]) if (g_actorCalls[i])
OSD_Printf(" [%5d]={ %8d, %9.3f, %9.3f },\n", OSD_Printf(" [%5d]={ %8d, %9.3f, %9.3f },\n",
@ -197,7 +214,7 @@ int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t
} }
Bassert(lua_type(L, -1)==LUA_TSTRING); Bassert(lua_type(L, -1)==LUA_TSTRING);
OSD_Printf("event \"%s\" (state \"%s\") runtime error: %s\n", EventNames[eventidx].text, OSD_Printf("event \"%s\" (state \"%s\") runtime error: %s\n", EventNames[eventidx],
estate->name, lua_tostring(L, -1)); // get err msg estate->name, lua_tostring(L, -1)); // get err msg
lua_pop(L, 1); lua_pop(L, 1);
return -1; return -1;