From 4e58984de594df0354c2670b2daaae75e5535629 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 5 Apr 2008 04:18:48 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@693 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/duke3d.h | 2 +- polymer/eduke32/source/gamedef.c | 14 ++++++++++++++ polymer/eduke32/source/gamedef.h | 3 +++ polymer/eduke32/source/gameexec.c | 15 +++++++++++++++ polymer/eduke32/source/gamevars.c | 4 ++-- polymer/eduke32/source/premap.c | 8 ++++++-- polymer/eduke32/source/savegame.c | 3 ++- 7 files changed, 43 insertions(+), 6 deletions(-) diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 58e62d406..8b6aa00cd 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -836,7 +836,7 @@ typedef struct { typedef struct { char *szLabel; - intptr_t *plValues; // array of values + int *plValues; // array of values int size; char bReset; } gamearray_t; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index eddde06e0..ccb3e11f9 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -447,6 +447,9 @@ static const char *keyw[] = "rotatesprite16", // 315 "gamearray", // 316 "setarray", // 317 + "resizearray", // 318 + "writearraytofile", // 319 + "readarrayfromfile", // 320 "" }; @@ -3371,6 +3374,16 @@ static int parsecommand(void) textptr++; transvar(); 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: if (!CheckEventSync(current_event)) ReportError(WARNING_EVENTSYNC); @@ -4508,6 +4521,7 @@ repeatcase: cheatkey[0] = *(scriptptr-1); transnum(LABEL_DEFINE); cheatkey[1] = *(scriptptr-1); + scriptptr -= 2; return 0; case CON_DEFINECHEAT: diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index f2be415ab..ca06c2fb9 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -807,4 +807,7 @@ enum keywords CON_ROTATESPRITE16, // 315 CON_GAMEARRAY, // 316 CON_SETARRAY, // 317 + CON_RESIZEARRAY, // 318 + CON_WRITEARRAYTOFILE, // 319 + CON_READARRAYFROMFILE, // 320 }; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index fabcc1130..3d2c61ad1 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -6776,6 +6776,7 @@ static int parse(void) SetGameVarID(*insptr, *(insptr+1), g_i, g_p); insptr += 2; break; + case CON_SETARRAY: insptr++; j=*insptr++; @@ -6787,6 +6788,20 @@ static int parse(void) 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: insptr++; SetGameVarID(*insptr, mulscale(krand(), *(insptr+1)+1, 16), g_i, g_p); diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index f7ea9c7f9..73f824b44 100755 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -172,7 +172,7 @@ int ReadGameVars(int fil) { //Bsprintf(g_szBuf,"Reading value array for %s (%d)",aGameVars[i].szLabel,sizeof(int) * MAXPLAYERS); //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__); @@ -255,7 +255,7 @@ void SaveGameVars(FILE *fil) for (i=0;igm = MODE_GAME; ud.recstat = 0;