Made fta_quotes dynamically allocated at compile time

git-svn-id: https://svn.eduke32.com/eduke32@92 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-04-23 02:20:42 +00:00
parent 2455734c76
commit 8d6f8eecda
10 changed files with 55 additions and 51 deletions

View file

@ -431,7 +431,7 @@ extern short int global_random;
extern long scaredfallz; extern long scaredfallz;
extern char buf[1024]; //My own generic input buffer extern char buf[1024]; //My own generic input buffer
extern char fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; extern char *fta_quotes[NUMOFFIRSTTIMEACTIVE];
extern char scantoasc[128],ready2send; extern char scantoasc[128],ready2send;
extern char scantoascwithshift[128]; extern char scantoascwithshift[128];

View file

@ -2076,7 +2076,8 @@ void FTA(short q,struct player_struct *p)
p->ftq = q; p->ftq = q;
pub = NUMPAGES; pub = NUMPAGES;
pus = NUMPAGES; pus = NUMPAGES;
if (p == &ps[screenpeek]) OSD_Printf("%s\n",fta_quotes[q]); if (p == &ps[screenpeek])
OSD_Printf("%s\n",fta_quotes[q]);
} }
} }
} }
@ -6648,10 +6649,8 @@ FOUNDCHEAT:
sprite[ps[myconnectindex].i].hitag = 0; sprite[ps[myconnectindex].i].hitag = 0;
sprite[ps[myconnectindex].i].lotag = 0; sprite[ps[myconnectindex].i].lotag = 0;
sprite[ps[myconnectindex].i].pal = sprite[ps[myconnectindex].i].pal = ps[myconnectindex].palookup;
ps[myconnectindex].palookup; Bstrcpy(fta_quotes[122],"Scream for me, Long Beach!");
Bsprintf(fta_quotes[122],"Scream for me, Long Beach!");
FTA(122,&ps[myconnectindex]); FTA(122,&ps[myconnectindex]);
} }
else else
@ -7054,8 +7053,7 @@ void nonsharedkeys(void)
music_select++; music_select++;
if(music_select == i) if(music_select == i)
music_select = 0; music_select = 0;
Bstrcpy(&fta_quotes[26][0],"PLAYING "); Bsprintf(fta_quotes[26],"PLAYING %s",&music_fn[0][music_select][0]);
Bstrcat(&fta_quotes[26][0],&music_fn[0][music_select][0]);
FTA(26,&ps[myconnectindex]); FTA(26,&ps[myconnectindex]);
playmusic(&music_fn[0][music_select][0]); playmusic(&music_fn[0][music_select][0]);
return; return;
@ -7273,9 +7271,8 @@ FAKE_F3:
if( KB_KeyPressed( sc_F5 ) && MusicDevice >= 0 ) if( KB_KeyPressed( sc_F5 ) && MusicDevice >= 0 )
{ {
KB_ClearKeyDown( sc_F5 ); KB_ClearKeyDown( sc_F5 );
strcpy(&tempbuf[0],&music_fn[0][music_select][0]); Bstrcpy(fta_quotes[26],&music_fn[0][music_select][0]);
strcat(&tempbuf[0],". USE SHIFT-F5 TO CHANGE."); Bstrcat(fta_quotes[26],". USE SHIFT-F5 TO CHANGE.");
strcpy(&fta_quotes[26][0],&tempbuf[0]);
FTA(26,&ps[myconnectindex]); FTA(26,&ps[myconnectindex]);
} }
@ -9618,13 +9615,12 @@ char domovethings(void)
if(multiwho != myconnectindex) if(multiwho != myconnectindex)
{ {
strcpy(fta_quotes[122],&ud.user_name[multiwho][0]); Bsprintf(fta_quotes[122],"%s SAVED A MULTIPLAYER GAME",&ud.user_name[multiwho][0]);
strcat(fta_quotes[122]," SAVED A MULTIPLAYER GAME");
FTA(122,&ps[myconnectindex]); FTA(122,&ps[myconnectindex]);
} }
else else
{ {
strcpy(fta_quotes[122],"MULTIPLAYER GAME SAVED"); Bstrcpy(fta_quotes[122],"MULTIPLAYER GAME SAVED");
FTA(122,&ps[myconnectindex]); FTA(122,&ps[myconnectindex]);
} }
break; break;
@ -9641,13 +9637,12 @@ char domovethings(void)
{ {
if(multiwho != myconnectindex) if(multiwho != myconnectindex)
{ {
strcpy(fta_quotes[122],&ud.user_name[multiwho][0]); Bsprintf(fta_quotes[122],"%s LOADED A MULTIPLAYER GAME",&ud.user_name[multiwho][0]);
strcat(fta_quotes[122]," LOADED A MULTIPLAYER GAME");
FTA(122,&ps[myconnectindex]); FTA(122,&ps[myconnectindex]);
} }
else else
{ {
strcpy(fta_quotes[122],"MULTIPLAYER GAME LOADED"); Bstrcpy(fta_quotes[122],"MULTIPLAYER GAME LOADED");
FTA(122,&ps[myconnectindex]); FTA(122,&ps[myconnectindex]);
} }
return 1; return 1;
@ -9712,6 +9707,7 @@ char domovethings(void)
Bsprintf(buf,"%s is history!",ud.user_name[i]); Bsprintf(buf,"%s is history!",ud.user_name[i]);
adduserquote(buf); adduserquote(buf);
Bstrcpy(fta_quotes[116],buf); Bstrcpy(fta_quotes[116],buf);
ps[myconnectindex].ftq = 116, ps[myconnectindex].fta = 60; ps[myconnectindex].ftq = 116, ps[myconnectindex].fta = 60;
if(j < 0 && networkmode == 0 ) if(j < 0 && networkmode == 0 )

View file

@ -41,8 +41,8 @@ signed char checking_switch = 0, current_event = -1;
char labelsonly = 0, nokeywordcheck = 0, dynamicremap = 0; char labelsonly = 0, nokeywordcheck = 0, dynamicremap = 0;
static short num_braces = 0; // init to some sensible defaults static short num_braces = 0; // init to some sensible defaults
char redefined_fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; char *redefined_quotes[NUMOFFIRSTTIMEACTIVE];
int redefined_quotes = 0; int redefined_quote_count = 0;
long *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine long *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine
long *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) long *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire)
@ -4539,7 +4539,11 @@ repeatcase:
} }
if (tw == CON_DEFINEQUOTE) if (tw == CON_DEFINEQUOTE)
{
if(fta_quotes[k] == NULL)
fta_quotes[k] = Bmalloc(sizeof(char) * 64);
scriptptr--; scriptptr--;
}
i = 0; i = 0;
@ -4547,7 +4551,11 @@ repeatcase:
textptr++; textptr++;
if (tw == CON_REDEFINEQUOTE) if (tw == CON_REDEFINEQUOTE)
redefined_quotes++; {
redefined_quote_count++;
if(redefined_quotes[redefined_quote_count] == NULL)
redefined_quotes[redefined_quote_count] = Bmalloc(sizeof(char) * 64);
}
while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 )
{ {
@ -4559,23 +4567,26 @@ repeatcase:
break; break;
} }
if (tw == CON_DEFINEQUOTE) if (tw == CON_DEFINEQUOTE)
fta_quotes[k][i] = *textptr; *(fta_quotes[k]+i) = *textptr;
else redefined_fta_quotes[redefined_quotes][i] = *textptr; else
*(redefined_quotes[redefined_quote_count]+i) = *textptr;
textptr++,i++; textptr++,i++;
if(i >= (signed)sizeof(fta_quotes[k])-1) if(i >= 63)
{ {
initprintf("%s:%ld: error: quote text exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(fta_quotes[k])-1); initprintf("%s:%ld: error: quote text exceeds limit of %ld characters.\n",compilefile,line_number,63);
error++; error++;
while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++; while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++;
break; break;
} }
} }
if (tw == CON_DEFINEQUOTE) if (tw == CON_DEFINEQUOTE)
fta_quotes[k][i] = '\0'; {
*(fta_quotes[k]+i) = '\0';
}
else else
{ {
redefined_fta_quotes[redefined_quotes][i] = '\0'; *(fta_quotes[redefined_quote_count]+i) = '\0';
*scriptptr++=redefined_quotes; *scriptptr++=redefined_quote_count;
} }
return 0; return 0;

View file

@ -39,7 +39,7 @@ extern long *actorLoadEventScrptr[MAXTILES];
extern long *apScriptGameEvent[MAXGAMEEVENTS]; extern long *apScriptGameEvent[MAXGAMEEVENTS];
extern char redefined_fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; extern char *redefined_quotes[NUMOFFIRSTTIMEACTIVE];
extern short otherp; extern short otherp;
extern long g_currentweapon; extern long g_currentweapon;

View file

@ -3408,7 +3408,7 @@ char parse(void)
insptr++; insptr++;
q = *insptr++; q = *insptr++;
i = *insptr++; i = *insptr++;
Bstrcpy(fta_quotes[q],redefined_fta_quotes[i]); Bstrcpy(fta_quotes[q],redefined_quotes[i]);
break; break;
} }
@ -4107,15 +4107,19 @@ SKIPJIBS:
switch(tw) switch(tw)
{ {
case CON_GETPNAME: case CON_GETPNAME:
if (ud.user_name[j][0] != 0) if (ud.user_name[j][0])
Bsprintf(fta_quotes[i],ud.user_name[j]); Bsprintf(fta_quotes[i],"%s",ud.user_name[j]);
else Bsprintf(fta_quotes[i],"%d",j); else
Bsprintf(fta_quotes[i],"%d",j);
break; break;
case CON_QSTRCAT: case CON_QSTRCAT:
Bstrncat(fta_quotes[i],fta_quotes[j],63-Bstrlen(fta_quotes[i])); Bmemcpy(tempbuf,fta_quotes[i],64);
Bmemcpy(buf,fta_quotes[j],64);
Bstrncat(tempbuf,buf,63-Bstrlen(tempbuf));
Bmemcpy(fta_quotes[i],tempbuf,64);
break; break;
case CON_QSTRCPY: case CON_QSTRCPY:
Bstrcpy(fta_quotes[i],fta_quotes[j]); Bstrcpy(fta_quotes[j],fta_quotes[i]);
break; break;
case CON_CHANGESPRITESTAT: case CON_CHANGESPRITESTAT:
changespritestat(i,j); changespritestat(i,j);
@ -4613,7 +4617,6 @@ SKIPJIBS:
x2=GetGameVarID(*insptr++,g_i,g_p); x2=GetGameVarID(*insptr++,g_i,g_p);
y2=GetGameVarID(*insptr++,g_i,g_p); y2=GetGameVarID(*insptr++,g_i,g_p);
} }
if (tw == CON_MINITEXT) minitextshade(x,y,fta_quotes[q],shade,pal,26); if (tw == CON_MINITEXT) minitextshade(x,y,fta_quotes[q],shade,pal,26);
else if (tw == CON_GAMETEXT) txgametext(tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2); else if (tw == CON_GAMETEXT) txgametext(tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2);
else if (tw == CON_DIGITALNUMBER) txdigitalnumber(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2); else if (tw == CON_DIGITALNUMBER) txdigitalnumber(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2);

View file

@ -42,7 +42,7 @@ short animatesect[MAXANIMATES];
long msx[2048],msy[2048]; long msx[2048],msy[2048];
short cyclers[MAXCYCLERS][6],numcyclers; short cyclers[MAXCYCLERS][6],numcyclers;
char fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; char *fta_quotes[NUMOFFIRSTTIMEACTIVE];
char tempbuf[2048], packbuf[576]; char tempbuf[2048], packbuf[576];

View file

@ -3468,16 +3468,16 @@ void processinput(short snum)
ps[p->frag_ps].frag++; ps[p->frag_ps].frag++;
frags[p->frag_ps][snum]++; frags[p->frag_ps][snum]++;
if( ud.user_name[p->frag_ps][0] != 0) if(ud.user_name[p->frag_ps][0])
{ {
if(snum == screenpeek) if(snum == screenpeek)
{ {
Bsprintf(&fta_quotes[115][0],"KILLED BY %s",&ud.user_name[p->frag_ps][0]); Bsprintf(fta_quotes[115],"KILLED BY %s",&ud.user_name[p->frag_ps][0]);
FTA(115,p); FTA(115,p);
} }
else else
{ {
Bsprintf(&fta_quotes[116][0],"KILLED %s",&ud.user_name[snum][0]); Bsprintf(fta_quotes[116],"KILLED %s",&ud.user_name[snum][0]);
FTA(116,&ps[p->frag_ps]); FTA(116,&ps[p->frag_ps]);
} }
} }
@ -3485,12 +3485,12 @@ void processinput(short snum)
{ {
if(snum == screenpeek) if(snum == screenpeek)
{ {
Bsprintf(&fta_quotes[115][0],"KILLED BY PLAYER %d",1+p->frag_ps); Bsprintf(fta_quotes[115],"KILLED BY PLAYER %d",p->frag_ps);
FTA(115,p); FTA(115,p);
} }
else else
{ {
Bsprintf(&fta_quotes[116][0],"KILLED PLAYER %d",1+snum); Bsprintf(fta_quotes[116],"KILLED PLAYER %d",snum);
FTA(116,&ps[p->frag_ps]); FTA(116,&ps[p->frag_ps]);
} }
} }

View file

@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int loadpheader(char spot,struct savehead *saveh) int loadpheader(char spot,struct savehead *saveh)
{ {
long i;
char fn[13]; char fn[13];
long fil; long fil;
long bv; long bv;

View file

@ -1002,7 +1002,7 @@ void operaterespawns(short low)
void operateactivators(short low,short snum) void operateactivators(short low,short snum)
{ {
short i, j, k, *p, nexti; short i, j, k, *p;
walltype *wal; walltype *wal;
for(i=numcyclers-1;i>=0;i--) for(i=numcyclers-1;i>=0;i--)
@ -1610,10 +1610,7 @@ void breakwall(short newpn,short spr,short dawallnum)
void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith) void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith)
{ {
short j, i, sn = -1, darkestwall; short j, i, sn = -1, darkestwall;
signed char nfloors,nceilings;
short nextj;
walltype *wal; walltype *wal;
spritetype *s;
wal = &wall[dawallnum]; wal = &wall[dawallnum];
@ -1932,9 +1929,7 @@ void checkplayerhurt(struct player_struct *p,short j)
char checkhitceiling(short sn) char checkhitceiling(short sn)
{ {
short i, j, q, darkestwall, darkestceiling; short i, j;
signed char nfloors,nceilings;
walltype *wal;
switch(dynamictostatic[sector[sn].ceilingpicnum]) switch(dynamictostatic[sector[sn].ceilingpicnum])
{ {
@ -2007,7 +2002,7 @@ char checkhitceiling(short sn)
void checkhitsprite(short i,short sn) void checkhitsprite(short i,short sn)
{ {
short j, k, l, nextj, p, rpg=0; short j, k, p, rpg=0;
spritetype *s; spritetype *s;
int switchpicnum; int switchpicnum;

View file

@ -232,7 +232,7 @@ char loadsound(unsigned short num)
fp = kopen4load(sounds[num],loadfromgrouponly); fp = kopen4load(sounds[num],loadfromgrouponly);
if(fp == -1) if(fp == -1)
{ {
sprintf(&fta_quotes[113][0],"Sound %s(#%d) not found.",sounds[num],num); Bsprintf(fta_quotes[113],"Sound %s(#%d) not found.",sounds[num],num);
FTA(113,&ps[myconnectindex]); FTA(113,&ps[myconnectindex]);
return 0; return 0;
} }