From 127bc3fe915c1cd36de87ef62fd5d4ff0412064d Mon Sep 17 00:00:00 2001 From: terminx Date: Mon, 25 Aug 2008 10:27:18 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@1029 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/eduke32.sln | 4 +- polymer/eduke32/eduke32.vcproj | 3 +- polymer/eduke32/source/astub.c | 6 +-- polymer/eduke32/source/config.c | 5 ++- polymer/eduke32/source/duke3d.h | 1 + polymer/eduke32/source/game.c | 22 ++++++---- polymer/eduke32/source/gamedef.c | 71 +++++++++++++++++++++++--------- 7 files changed, 79 insertions(+), 33 deletions(-) diff --git a/polymer/eduke32/eduke32.sln b/polymer/eduke32/eduke32.sln index 8751f0e44..d14894d24 100644 --- a/polymer/eduke32/eduke32.sln +++ b/polymer/eduke32/eduke32.sln @@ -1,6 +1,6 @@  -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eduke32", "eduke32.vcproj", "{8E7A6179-0B72-4073-8A4C-E8682D481DAE}" EndProject Global diff --git a/polymer/eduke32/eduke32.vcproj b/polymer/eduke32/eduke32.vcproj index fde883174..d903387e2 100644 --- a/polymer/eduke32/eduke32.vcproj +++ b/polymer/eduke32/eduke32.vcproj @@ -1,11 +1,12 @@ =0;j--) { - if (tilesizx[sprite[j].picnum]==0 || tilesizy[sprite[j].picnum]==0) - sprite[j].picnum=0; +/* if (tilesizx[sprite[j].picnum]==0 || tilesizy[sprite[j].picnum]==0) + sprite[j].picnum=0; */ if (sprite[j].picnum>=20 && sprite[j].picnum<=59) { diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 7d5651392..e96d0e91a 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -404,7 +404,7 @@ void CONFIG_MapKey(int32 which, kb_scancode key1, kb_scancode oldkey1, kb_scanco boundkeys[ii[k]].cmd[0] = 0; tempbuf[0] = 0; - for (i=0;i=0;i--) { if (ud.config.KeyboardKeys[i][0] == ii[k] || ud.config.KeyboardKeys[i][1] == ii[k]) { @@ -594,6 +594,7 @@ int32 CONFIG_ReadSetup(void) int32 dummy, i = 0; char commmacro[] = "CommbatMacro# "; extern int32 CommandWeaponChoice; + char tempbuf[1024]; CONTROL_ClearAssignments(); CONFIG_SetDefaults(); @@ -863,6 +864,7 @@ void CONFIG_WriteBinds(void) // save binds and aliases to disk int i; FILE *fp; char *ptr = Bstrdup(setupfilename); + char tempbuf[128]; Bsprintf(tempbuf,"%s_binds.cfg",strtok(ptr,".")); fp = fopen(tempbuf, "wt"); @@ -901,6 +903,7 @@ void CONFIG_WriteBinds(void) // save binds and aliases to disk void CONFIG_WriteSetup(void) { int32 dummy; + char tempbuf[1024]; if (!ud.config.setupread) return; diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 3876ebe13..0a434c1a0 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -790,6 +790,7 @@ enum events { EVENT_DISPLAYMENUREST, EVENT_DISPLAYLOADINGSCREEN, EVENT_ANIMATESPRITES, + MAXEVENTS }; enum sysstrs { diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 97d498eb4..3fb0b6bca 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -4643,10 +4643,10 @@ int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr, ResetActorGameVars(i); hittype[i].flags = 0; + if (apScriptGameEvent[EVENT_EGS]) { int pl=findplayer(&sprite[i],&p); - if (apScriptGameEvent[EVENT_EGS]) - OnEvent(EVENT_EGS,i, pl, p); + OnEvent(EVENT_EGS,i, pl, p); } return(i); @@ -6363,8 +6363,16 @@ int spawn(int j, int pn) } if (j == -1) { - Bsprintf(tempbuf,"Found lonely Sector Effector (lotag 0) at (%d,%d)\n",sp->x,sp->y); - gameexit(tempbuf); +// Bsprintf(tempbuf,"Found lonely Sector Effector (lotag 0) at (%d,%d)\n",sp->x,sp->y); +// gameexit(tempbuf); + OSD_Printf(OSD_ERROR "Found lonely Sector Effector (lotag 0) at (%d,%d)\n",sp->x,sp->y); + changespritestat(i,1); + if (apScriptGameEvent[EVENT_SPAWN]) + { + int pl=findplayer(&sprite[i],&p); + OnEvent(EVENT_SPAWN,i, pl, p); + } + return i; } sp->owner = j; } @@ -6576,10 +6584,10 @@ int spawn(int j, int pn) break; } + if (apScriptGameEvent[EVENT_SPAWN]) { int pl=findplayer(&sprite[i],&p); - if (apScriptGameEvent[EVENT_SPAWN]) - OnEvent(EVENT_SPAWN,i, pl, p); + OnEvent(EVENT_SPAWN,i, pl, p); } return i; @@ -7437,7 +7445,7 @@ PALONLY: if (j < 0) return; if (display_mirror) tsprite[j].statnum = TSPR_MIRROR; - if (spriteext[tsprite[j].owner].flags & SPREXT_TSPRACCESS && tsprite[j].owner < MAXSPRITES && tsprite[j].owner > 0) + if (tsprite[j].owner > 0 && tsprite[j].owner < MAXSPRITES && spriteext[tsprite[j].owner].flags & SPREXT_TSPRACCESS) { OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1); spriteext[tsprite[j].owner].tspr = NULL; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index a9e3e2318..7d593f104 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1072,8 +1072,14 @@ static int increasescriptsize(int size) } //initprintf("offset: %d\n",(unsigned)(scriptptr-script)); - g_ScriptSize = size; - initprintf("Increasing script buffer size to %d bytes...\n",g_ScriptSize * sizeof(intptr_t)); + if (size <= g_ScriptSize) + initprintf("Shrinking bytecode buffer, final size: %d*%d bytes\n",g_ScriptSize, sizeof(intptr_t)); + else + { + g_ScriptSize = size; + initprintf("Increasing bytecode buffer to %d*%d bytes...\n",g_ScriptSize, sizeof(intptr_t)); + } + newscript = (intptr_t *)Brealloc(script, g_ScriptSize * sizeof(intptr_t)); if (newscript == NULL) @@ -1084,11 +1090,17 @@ static int increasescriptsize(int size) error++; return 1; } - Bmemset(&newscript[osize],0,(size-osize) * sizeof(intptr_t)); + + bitptr = (char *)Brealloc(bitptr, g_ScriptSize * sizeof(char)); + + if (size > osize) + { + Bmemset(&newscript[osize],0,(size-osize) * sizeof(intptr_t)); + Bmemset(&bitptr[osize],0,size-osize); + } + script = newscript; scriptptr = (intptr_t *)(script+oscriptptr); - bitptr = (char *)Brealloc(bitptr, g_ScriptSize * sizeof(char)); - Bmemset(&bitptr[osize],0,size-osize); // initprintf("script: %d, bitptr: %d\n",script,bitptr); //initprintf("offset: %d\n",(unsigned)(scriptptr-script)); @@ -1107,12 +1119,24 @@ static int increasescriptsize(int size) } } - for (i=g_ScriptSize-(size-osize)-1;i>=0;i--) - if (scriptptrs[i]) - { - j = (intptr_t)script[i]+(intptr_t)&script[0]; - script[i] = j; - } + if (size > osize) + { + for (i=g_ScriptSize-(size-osize)-1;i>=0;i--) + if (scriptptrs[i]) + { + j = (intptr_t)script[i]+(intptr_t)&script[0]; + script[i] = j; + } + } + else + { + for (i=g_ScriptSize-1;i>=0;i--) + if (scriptptrs[i]) + { + j = (intptr_t)script[i]+(intptr_t)&script[0]; + script[i] = j; + } + } for (i=MAXTILES-1;i>=0;i--) { @@ -1187,7 +1211,7 @@ static int skipcomments(void) } if ((unsigned)(scriptptr-script) > (unsigned)(g_ScriptSize-32)) - return increasescriptsize(g_ScriptSize+16384); + return increasescriptsize(g_ScriptSize<<1); return 0; } @@ -5618,20 +5642,29 @@ void loadefs(const char *filenam) int j=0, k=0; total_lines += line_number; + + while ((g_ScriptSize-1024) > (scriptptr-script)) + g_ScriptSize -= 1024; + increasescriptsize(g_ScriptSize); + + initprintf("Compiled code size: %ld*%d bytes, version %s\n",(unsigned)(scriptptr-script),sizeof(intptr_t),(g_ScriptVersion == 14?"1.4+":"1.3D")); + initprintf("%ld/%ld labels, %d/%d variables\n",labelcnt,min((MAXSECTORS * sizeof(sectortype)/sizeof(int)),(MAXSPRITES * sizeof(spritetype)/(1<<6))),iGameVarCount,MAXGAMEVARS); + + for (i=MAXQUOTES-1;i>=0;i--) + if (fta_quotes[i]) + j++; + + initprintf("%ld/%d quotes, %d quote redefinitions\n",j,MAXQUOTES,redefined_quote_count); + + j = 0; for (i=MAXGAMEEVENTS-1;i>=0;i--) - { if (apScriptGameEvent[i]) j++; - } for (i=MAXTILES-1;i>=0;i--) - { if (actorscrptr[i]) k++; - } - initprintf("Compiled code size: %ld bytes, version %s\n",(unsigned)(scriptptr-script) * sizeof(intptr_t),(g_ScriptVersion == 14?"1.4+":"1.3D")); - initprintf("%ld/%ld labels, %d/%d variables\n",labelcnt,min((MAXSECTORS * sizeof(sectortype)/sizeof(int)),(MAXSPRITES * sizeof(spritetype)/(1<<6))),iGameVarCount,MAXGAMEVARS); - initprintf("%ld event definitions, %ld defined actors\n",j,k); + initprintf("%ld/%d event definitions, %ld defined actors\n",j,MAXEVENTS,k); for (i=127;i>=0;i--) if (fta_quotes[i] == NULL)