git-svn-id: https://svn.eduke32.com/eduke32@693 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-04-05 04:18:48 +00:00
parent ec7c642585
commit 4e58984de5
7 changed files with 43 additions and 6 deletions

View file

@ -836,7 +836,7 @@ typedef struct {
typedef struct { typedef struct {
char *szLabel; char *szLabel;
intptr_t *plValues; // array of values int *plValues; // array of values
int size; int size;
char bReset; char bReset;
} gamearray_t; } gamearray_t;

View file

@ -447,6 +447,9 @@ static const char *keyw[] =
"rotatesprite16", // 315 "rotatesprite16", // 315
"gamearray", // 316 "gamearray", // 316
"setarray", // 317 "setarray", // 317
"resizearray", // 318
"writearraytofile", // 319
"readarrayfromfile", // 320
"<null>" "<null>"
}; };
@ -3371,6 +3374,16 @@ static int parsecommand(void)
textptr++; textptr++;
transvar(); transvar();
return 0; return 0;
case CON_RESIZEARRAY:
getlabel();
i=GetADefID(label+(labelcnt<<6));
if (i > (-1))
*scriptptr++=i;
else
ReportError(ERROR_NOTAGAMEARRAY);
skipcomments();
transvar();
return 0;
case CON_RANDVARVAR: case CON_RANDVARVAR:
if (!CheckEventSync(current_event)) if (!CheckEventSync(current_event))
ReportError(WARNING_EVENTSYNC); ReportError(WARNING_EVENTSYNC);
@ -4508,6 +4521,7 @@ repeatcase:
cheatkey[0] = *(scriptptr-1); cheatkey[0] = *(scriptptr-1);
transnum(LABEL_DEFINE); transnum(LABEL_DEFINE);
cheatkey[1] = *(scriptptr-1); cheatkey[1] = *(scriptptr-1);
scriptptr -= 2;
return 0; return 0;
case CON_DEFINECHEAT: case CON_DEFINECHEAT:

View file

@ -807,4 +807,7 @@ enum keywords
CON_ROTATESPRITE16, // 315 CON_ROTATESPRITE16, // 315
CON_GAMEARRAY, // 316 CON_GAMEARRAY, // 316
CON_SETARRAY, // 317 CON_SETARRAY, // 317
CON_RESIZEARRAY, // 318
CON_WRITEARRAYTOFILE, // 319
CON_READARRAYFROMFILE, // 320
}; };

View file

@ -6776,6 +6776,7 @@ static int parse(void)
SetGameVarID(*insptr, *(insptr+1), g_i, g_p); SetGameVarID(*insptr, *(insptr+1), g_i, g_p);
insptr += 2; insptr += 2;
break; break;
case CON_SETARRAY: case CON_SETARRAY:
insptr++; insptr++;
j=*insptr++; j=*insptr++;
@ -6787,6 +6788,20 @@ static int parse(void)
break; break;
} }
case CON_RESIZEARRAY:
insptr++;
j=*insptr++;
{
int asize = GetGameVarID(*insptr++, g_i, g_p);
if (asize > 0)
{
OSD_Printf("resizing array %s, old size %d new size %d\n", aGameArrays[j].szLabel, aGameArrays[j].size, asize);
aGameArrays[j].plValues=Brealloc(aGameArrays[j].plValues, sizeof(int) * asize);
aGameArrays[j].size = asize;
}
break;
}
case CON_RANDVAR: case CON_RANDVAR:
insptr++; insptr++;
SetGameVarID(*insptr, mulscale(krand(), *(insptr+1)+1, 16), g_i, g_p); SetGameVarID(*insptr, mulscale(krand(), *(insptr+1)+1, 16), g_i, g_p);

View file

@ -172,7 +172,7 @@ int ReadGameVars(int fil)
{ {
//Bsprintf(g_szBuf,"Reading value array for %s (%d)",aGameVars[i].szLabel,sizeof(int) * MAXPLAYERS); //Bsprintf(g_szBuf,"Reading value array for %s (%d)",aGameVars[i].szLabel,sizeof(int) * MAXPLAYERS);
//AddLog(g_szBuf); //AddLog(g_szBuf);
if (kdfread(aGameArrays[i].plValues,sizeof(int) * aGameArrays[i].size, 1, fil) != 1) goto corrupt; if (kdfread(aGameArrays[i].plValues,sizeof(intptr_t) * aGameArrays[i].size, 1, fil) != 1) goto corrupt;
} }
// Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); // Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__);
@ -255,7 +255,7 @@ void SaveGameVars(FILE *fil)
for (i=0;i<iGameArrayCount;i++) for (i=0;i<iGameArrayCount;i++)
{ {
dfwrite(aGameArrays[i].plValues,sizeof(int) * aGameArrays[i].size, 1, fil); dfwrite(aGameArrays[i].plValues,sizeof(intptr_t) * aGameArrays[i].size, 1, fil);
} }
for (i=0;i<MAXGAMEEVENTS;i++) for (i=0;i<MAXGAMEEVENTS;i++)

View file

@ -401,8 +401,12 @@ void cacheit(void)
if (ud.recstat == 2) if (ud.recstat == 2)
return; return;
MUSIC_StopSong(); MUSIC_Pause();
playmusic(&env_music_fn[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus if (map[MAXVOLUMES*MAXLEVELS+2].musicfn1)
{
MUSIC_StopSong();
playmusic(&env_music_fn[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus
}
starttime = getticks(); starttime = getticks();

View file

@ -412,11 +412,12 @@ int loadplayer(int spot)
i = music_select; i = music_select;
music_select = (ud.volume_number*MAXLEVELS) + ud.level_number; music_select = (ud.volume_number*MAXLEVELS) + ud.level_number;
if (map[(unsigned char)music_select].musicfn != NULL && (i != music_select || env_music_fn[2][0])) if (map[(unsigned char)music_select].musicfn != NULL && (i != music_select || map[MAXVOLUMES*MAXLEVELS+2].musicfn1))
{ {
MUSIC_StopSong(); MUSIC_StopSong();
playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); playmusic(&map[(unsigned char)music_select].musicfn[0],music_select);
} }
MUSIC_Continue();
g_player[myconnectindex].ps->gm = MODE_GAME; g_player[myconnectindex].ps->gm = MODE_GAME;
ud.recstat = 0; ud.recstat = 0;