1. Runtime CON errors display the line numbers of CON now. It doesn't increase the size of compiled code because the line number assigned to each command of a CON file.

The lower 12 bits are used for the ID of command(up to 4096 IDs).
The rest 20 bits are used to store the line number(up to about 1 000 000 lines).
Perhabs variable errors need this too.

2. Fixed 2 crashes.


git-svn-id: https://svn.eduke32.com/eduke32@871 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hnt_ts 2008-07-19 19:06:21 +00:00
parent b45bb674d1
commit e8c0abf7da
4 changed files with 38 additions and 32 deletions

View file

@ -1401,7 +1401,7 @@ static int transword(void) //Returns its code #
{ {
if (Bstrcmp(tempbuf,keyw[i]) == 0) if (Bstrcmp(tempbuf,keyw[i]) == 0)
{ {
*scriptptr = i; *scriptptr = i + (line_number<<12);
textptr += l; textptr += l;
scriptptr++; scriptptr++;
if (!(error || warning) && g_ScriptDebug) if (!(error || warning) && g_ScriptDebug)

View file

@ -32,12 +32,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void restoremapstate(mapstate_t *save); void restoremapstate(mapstate_t *save);
void savemapstate(mapstate_t *save); void savemapstate(mapstate_t *save);
#define CON_ERROR OSDTEXT_DARKRED OSDTEXT_BRIGHT "Line %d, "
int g_i,g_p; int g_i,g_p;
static int g_x; static int g_x;
static intptr_t *g_t; static intptr_t *g_t;
static spritetype *g_sp; static spritetype *g_sp;
static int killit_flag; static int killit_flag;
int line_num;
static int parse(void); static int parse(void);
@ -878,7 +880,7 @@ static void DoThisProjectile(int iSet, int lVar1, int lLabelID, int lVar2)
if (proj < 0 || proj >= MAXSPRITES) if (proj < 0 || proj >= MAXSPRITES)
{ {
// OSD_Printf("DoThisProjectile(): invalid projectile (%d)\n",proj); // OSD_Printf("DoThisProjectile(): invalid projectile (%d)\n",proj);
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "DoThisProjectile(): tried to %s %s on invalid target projectile (%d) %d %d from %s\n", OSD_Printf(CON_ERROR "DoThisProjectile(): tried to %s %s on invalid target projectile (%d) %d %d from %s\n",line_num,
iSet?"set":"get",projectilelabels[lLabelID].name,proj,g_i,g_sp->picnum, iSet?"set":"get",projectilelabels[lLabelID].name,proj,g_i,g_sp->picnum,
(lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended"); (lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended");
insptr += (lVar2 == MAXGAMEVARS); insptr += (lVar2 == MAXGAMEVARS);
@ -1158,7 +1160,7 @@ static void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2)
if (iPlayer<0 || iPlayer >= ud.multimode) if (iPlayer<0 || iPlayer >= ud.multimode)
{ {
// OSD_Printf("DoPlayer(): invalid target player (%d) %d\n",iPlayer,g_i); // OSD_Printf("DoPlayer(): invalid target player (%d) %d\n",iPlayer,g_i);
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "DoPlayer(): tried to %s %s on invalid target player (%d) from spr %d gv %s\n", OSD_Printf(CON_ERROR "DoPlayer(): tried to %s %s on invalid target player (%d) from spr %d gv %s\n",line_num,
iSet?"set":"get",playerlabels[lLabelID].name,iPlayer,g_i, iSet?"set":"get",playerlabels[lLabelID].name,iPlayer,g_i,
(lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended"); (lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended");
insptr += (lVar2 == MAXGAMEVARS); insptr += (lVar2 == MAXGAMEVARS);
@ -1167,7 +1169,7 @@ static void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2)
if (lParm2 < 0 || lParm2 >= playerlabels[lLabelID].maxParm2) if (lParm2 < 0 || lParm2 >= playerlabels[lLabelID].maxParm2)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "DoPlayer(): tried to %s invalid %s position %d on player (%d) from spr %d\n", OSD_Printf(CON_ERROR "DoPlayer(): tried to %s invalid %s position %d on player (%d) from spr %d\n",line_num,
iSet?"set":"get",playerlabels[lLabelID].name,lParm2,iPlayer,g_i); iSet?"set":"get",playerlabels[lLabelID].name,lParm2,iPlayer,g_i);
insptr += (lVar2 == MAXGAMEVARS); insptr += (lVar2 == MAXGAMEVARS);
return; return;
@ -2507,7 +2509,7 @@ static void DoInput(int iSet, int lVar1, int lLabelID, int lVar2)
if (iPlayer<0 || iPlayer >= ud.multimode) if (iPlayer<0 || iPlayer >= ud.multimode)
{ {
insptr += (lVar2 == MAXGAMEVARS); insptr += (lVar2 == MAXGAMEVARS);
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "DoInput(): invalid target player (%d) %d\n",iPlayer,g_i); OSD_Printf(CON_ERROR "DoInput(): invalid target player (%d) %d\n",line_num,iPlayer,g_i);
return; return;
} }
@ -2988,7 +2990,7 @@ static void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2)
if (iActor < 0 || iActor >= MAXSPRITES) if (iActor < 0 || iActor >= MAXSPRITES)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "DoActor(): tried to %s %s on invalid target sprite (%d) from spr %d pic %d gv %s\n", OSD_Printf(CON_ERROR "DoActor(): tried to %s %s on invalid target sprite (%d) from spr %d pic %d gv %s\n",line_num,
iSet?"set":"get",actorlabels[lLabelID].name,iActor,g_i,g_sp->picnum, iSet?"set":"get",actorlabels[lLabelID].name,iActor,g_i,g_sp->picnum,
(lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended"); (lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended");
insptr += (lVar2 == MAXGAMEVARS); insptr += (lVar2 == MAXGAMEVARS);
@ -2997,7 +2999,7 @@ static void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2)
if (lParm2 < 0 || lParm2 >= actorlabels[lLabelID].maxParm2) if (lParm2 < 0 || lParm2 >= actorlabels[lLabelID].maxParm2)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "DoActor(): tried to %s invalid %s position %d on sprite (%d) from spr %d\n", OSD_Printf(CON_ERROR "DoActor(): tried to %s invalid %s position %d on sprite (%d) from spr %d\n",line_num,
iSet?"set":"get",actorlabels[lLabelID].name,lParm2,iActor,g_i); iSet?"set":"get",actorlabels[lLabelID].name,lParm2,iActor,g_i);
insptr += (lVar2 == MAXGAMEVARS); insptr += (lVar2 == MAXGAMEVARS);
return; return;
@ -3473,7 +3475,7 @@ static void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2)
if (iActor < 0 || iActor >= MAXSPRITES) if (iActor < 0 || iActor >= MAXSPRITES)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "DoTsprite(): invalid target sprite (%d) %d %d\n",iActor,g_i,g_sp->picnum); OSD_Printf(CON_ERROR "DoTsprite(): invalid target sprite (%d) %d %d\n",line_num,iActor,g_i,g_sp->picnum);
insptr += (lVar2 == MAXGAMEVARS); insptr += (lVar2 == MAXGAMEVARS);
return; return;
} }
@ -3614,7 +3616,7 @@ static void DoProjectile(int iSet, int lVar1, int lLabelID, int lVar2)
if (lVar1 < 0 || lVar1 >= MAXTILES) if (lVar1 < 0 || lVar1 >= MAXTILES)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "DoProjectile(): invalid tile (%d)\n",lVar1); OSD_Printf(CON_ERROR "DoProjectile(): invalid tile (%d)\n",line_num,lVar1);
insptr += (lVar2 == MAXGAMEVARS); insptr += (lVar2 == MAXGAMEVARS);
return; return;
} }
@ -3885,7 +3887,7 @@ void OnEvent(int iEventID, int iActor, int iPlayer, int lDist)
{ {
if (iEventID >= MAXGAMEEVENTS) if (iEventID >= MAXGAMEEVENTS)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "OnEvent(): invalid event ID"); OSD_Printf(CON_ERROR "OnEvent(): invalid event ID",line_num);
return; return;
} }
@ -4449,7 +4451,7 @@ static inline void parseifelse(int condition)
return; return;
} }
insptr = (intptr_t *) *(insptr+1); insptr = (intptr_t *) *(insptr+1);
if (*insptr == CON_ELSE) if (((*insptr)&0xFFF) == CON_ELSE)
{ {
// else... // else...
// skip 'else' and... // skip 'else' and...
@ -4470,6 +4472,9 @@ static int parse(void)
// Bsprintf(g_szBuf,"Parsing: %d",*insptr); // Bsprintf(g_szBuf,"Parsing: %d",*insptr);
// AddLog(g_szBuf); // AddLog(g_szBuf);
line_num = tw>>12;
tw &= 0xFFF;
switch (tw) switch (tw)
{ {
case CON_REDEFINEQUOTE: case CON_REDEFINEQUOTE:
@ -4478,7 +4483,7 @@ static int parse(void)
int q = *insptr++, i = *insptr++; int q = *insptr++, i = *insptr++;
if (fta_quotes[q] == NULL || redefined_quotes[i] == NULL) if (fta_quotes[q] == NULL || redefined_quotes[i] == NULL)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d %d\n",__FILE__,__LINE__,q,i); OSD_Printf(CON_ERROR "%s %d null quote %d %d\n",line_num,__FILE__,__LINE__,q,i);
break; break;
} }
Bstrcpy(fta_quotes[q],redefined_quotes[i]); Bstrcpy(fta_quotes[q],redefined_quotes[i]);
@ -5300,7 +5305,7 @@ static int parse(void)
Bstrcpy(fta_quotes[i],g_player[j].user_name); Bstrcpy(fta_quotes[i],g_player[j].user_name);
else Bsprintf(fta_quotes[i],"%d",j); else Bsprintf(fta_quotes[i],"%d",j);
} }
else OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d\n",__FILE__,__LINE__,i); else OSD_Printf(CON_ERROR "%s %d null quote %d\n",line_num,__FILE__,__LINE__,i);
break; break;
case CON_QGETSYSSTR: case CON_QGETSYSSTR:
if (fta_quotes[i] != NULL) if (fta_quotes[i] != NULL)
@ -5322,19 +5327,19 @@ static int parse(void)
Bstrcpy(fta_quotes[i],gametype_names[ud.coop]); Bstrcpy(fta_quotes[i],gametype_names[ud.coop]);
break; break;
default: default:
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d unknown str ID %d %d\n",__FILE__,__LINE__,i,j); OSD_Printf(CON_ERROR "%s %d unknown str ID %d %d\n",line_num,__FILE__,__LINE__,i,j);
} }
else OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d %d\n",__FILE__,__LINE__,i,j); else OSD_Printf(CON_ERROR "%s %d null quote %d %d\n",line_num,__FILE__,__LINE__,i,j);
break; break;
case CON_QSTRCAT: case CON_QSTRCAT:
if (fta_quotes[i] != NULL && fta_quotes[j] != NULL) if (fta_quotes[i] != NULL && fta_quotes[j] != NULL)
Bstrncat(fta_quotes[i],fta_quotes[j],(MAXQUOTELEN-1)-Bstrlen(fta_quotes[i])); Bstrncat(fta_quotes[i],fta_quotes[j],(MAXQUOTELEN-1)-Bstrlen(fta_quotes[i]));
else OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d %d\n",__FILE__,__LINE__,i,j); else OSD_Printf(CON_ERROR "%s %d null quote %d %d\n",line_num,__FILE__,__LINE__,i,j);
break; break;
case CON_QSTRCPY: case CON_QSTRCPY:
if (fta_quotes[i] != NULL && fta_quotes[j] != NULL) if (fta_quotes[i] != NULL && fta_quotes[j] != NULL)
Bstrcpy(fta_quotes[i],fta_quotes[j]); Bstrcpy(fta_quotes[i],fta_quotes[j]);
else OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d %d\n",__FILE__,__LINE__,i,j); else OSD_Printf(CON_ERROR "%s %d null quote %d %d\n",line_num,__FILE__,__LINE__,i,j);
break; break;
case CON_CHANGESPRITESTAT: case CON_CHANGESPRITESTAT:
changespritestat(i,j); changespritestat(i,j);
@ -5354,13 +5359,13 @@ static int parse(void)
if (volnume > MAXVOLUMES-1 || volnume < 0) if (volnume > MAXVOLUMES-1 || volnume < 0)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "CON_STARTLEVEL: invalid volume (%d)\n",volnume); OSD_Printf(CON_ERROR "CON_STARTLEVEL: invalid volume (%d)\n",line_num,volnume);
break; break;
} }
if (levnume > MAXLEVELS-1 || levnume < 0) if (levnume > MAXLEVELS-1 || levnume < 0)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "CON_STARTLEVEL: invalid level (%d)\n",levnume); OSD_Printf(CON_ERROR "CON_STARTLEVEL: invalid level (%d)\n",line_num,levnume);
break; break;
} }
@ -5519,7 +5524,7 @@ static int parse(void)
break; break;
} }
} }
else OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "CON_DIST/CON_LDIST: error: invalid sprite\n"); else OSD_Printf(CON_ERROR "CON_DIST/CON_LDIST: error: invalid sprite\n",line_num);
SetGameVarID(distvar, distx, g_i, g_p); SetGameVarID(distvar, distx, g_i, g_p);
break; break;
@ -5856,7 +5861,7 @@ static int parse(void)
int z=65536; int z=65536;
if (fta_quotes[q] == NULL) if (fta_quotes[q] == NULL)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d\n",__FILE__,__LINE__,q); OSD_Printf(CON_ERROR "%s %d null quote %d\n",line_num,__FILE__,__LINE__,q);
break; break;
} }
if (tw == CON_GAMETEXTZ)z=GetGameVarID(*insptr++,g_i,g_p); if (tw == CON_GAMETEXTZ)z=GetGameVarID(*insptr++,g_i,g_p);
@ -5870,7 +5875,7 @@ static int parse(void)
if (fta_quotes[q] == NULL) if (fta_quotes[q] == NULL)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d\n",__FILE__,__LINE__,q); OSD_Printf(CON_ERROR "%s %d null quote %d\n",line_num,__FILE__,__LINE__,q);
break; break;
} }
minitextshade(x,y,fta_quotes[q],shade,pal,26); minitextshade(x,y,fta_quotes[q],shade,pal,26);
@ -6536,8 +6541,8 @@ static int parse(void)
Bsprintf(fta_quotes[dq],tempbuf,var1,var2,var3,var4); Bsprintf(fta_quotes[dq],tempbuf,var1,var2,var3,var4);
break; break;
} }
if (fta_quotes[sq] == NULL) OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d\n",__FILE__,__LINE__,sq); if (fta_quotes[sq] == NULL) OSD_Printf(CON_ERROR "%s %d null quote %d\n",line_num,__FILE__,__LINE__,sq);
if (fta_quotes[dq] == NULL) OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d\n",__FILE__,__LINE__,dq); if (fta_quotes[dq] == NULL) OSD_Printf(CON_ERROR "%s %d null quote %d\n",line_num,__FILE__,__LINE__,dq);
insptr += 4; insptr += 4;
break; break;
} }
@ -6583,7 +6588,7 @@ static int parse(void)
} }
else else
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "CONLOGVAR: L=%d INVALID ARRAY INDEX\n",l); OSD_Printf(CON_ERROR "CONLOGVAR: L=%d INVALID ARRAY INDEX\n",line_num,l);
break; break;
} }
} }
@ -6596,7 +6601,7 @@ static int parse(void)
{ {
// invalid varID // invalid varID
insptr++; insptr++;
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "CONLOGVAR: L=%d INVALID VARIABLE\n",l); OSD_Printf(CON_ERROR "CONLOGVAR: L=%d INVALID VARIABLE\n",line_num,l);
break; // out of switch break; // out of switch
} }
} }
@ -7482,14 +7487,14 @@ static int parse(void)
if (fta_quotes[*insptr] == NULL) if (fta_quotes[*insptr] == NULL)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d\n",__FILE__,__LINE__,*insptr); OSD_Printf(CON_ERROR "%s %d null quote %d\n",line_num,__FILE__,__LINE__,*insptr);
insptr++; insptr++;
break; break;
} }
if (g_p < 0 || g_p >= MAXPLAYERS) if (g_p < 0 || g_p >= MAXPLAYERS)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "CON_QUOTE: bad player for quote %d: (%d)\n",*insptr,g_p); OSD_Printf(CON_ERROR "CON_QUOTE: bad player for quote %d: (%d)\n",line_num,*insptr,g_p);
insptr++; insptr++;
break; break;
} }
@ -7504,7 +7509,7 @@ static int parse(void)
if (fta_quotes[i] == NULL) if (fta_quotes[i] == NULL)
{ {
OSD_Printf(OSDTEXT_DARKRED OSDTEXT_BRIGHT "%s %d null quote %d\n",__FILE__,__LINE__,i); OSD_Printf(CON_ERROR "%s %d null quote %d\n",line_num,__FILE__,__LINE__,i);
break; break;
} }
adduserquote(fta_quotes[i]); adduserquote(fta_quotes[i]);

View file

@ -4003,7 +4003,7 @@ void processinput(int snum)
p->scream_voice = spritesound(DUKE_SCREAM,pi); p->scream_voice = spritesound(DUKE_SCREAM,pi);
} }
if ((p->posz+p->poszv) >= (fz-(i<<8))) // hit the ground if ((p->posz+p->poszv) >= (fz-(i<<8)) && p->cursectnum >= 0) // hit the ground
if (sector[p->cursectnum].lotag != 1) if (sector[p->cursectnum].lotag != 1)
{ {
if (p->falling_counter > 62) quickkill(p); if (p->falling_counter > 62) quickkill(p);

View file

@ -89,12 +89,12 @@ int loadpheader(char spot,struct savehead *saveh)
// AddLog(g_szBuf); // AddLog(g_szBuf);
if (kdfread(&bv,4,1,fil) != 1) goto corrupt; if (kdfread(&bv,4,1,fil) != 1) goto corrupt;
if (bv != BYTEVERSION) /* if (bv != BYTEVERSION)
{ {
FTA(114,g_player[myconnectindex].ps); FTA(114,g_player[myconnectindex].ps);
kclose(fil); kclose(fil);
return 1; return 1;
} }*/
if (kdfread(&saveh->numplr,sizeof(int32),1,fil) != 1) goto corrupt; if (kdfread(&saveh->numplr,sizeof(int32),1,fil) != 1) goto corrupt;
@ -270,6 +270,7 @@ int loadplayer(int spot)
if (kdfread(&cloudy[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; if (kdfread(&cloudy[0],sizeof(short)<<7,1,fil) != 1) goto corrupt;
if (kdfread(&g_ScriptSize,sizeof(g_ScriptSize),1,fil) != 1) goto corrupt; if (kdfread(&g_ScriptSize,sizeof(g_ScriptSize),1,fil) != 1) goto corrupt;
if (!g_ScriptSize) goto corrupt;
scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(scriptptrs)); scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(scriptptrs));
if (kdfread(&scriptptrs[0],sizeof(scriptptrs),g_ScriptSize,fil) != g_ScriptSize) goto corrupt; if (kdfread(&scriptptrs[0],sizeof(scriptptrs),g_ScriptSize,fil) != g_ScriptSize) goto corrupt;
if (script != NULL) if (script != NULL)