From 4ad4350d483725b64eb0e320313397b332fa4158 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 16 Aug 2008 07:53:29 +0000 Subject: [PATCH] Line numbering stuff... this still needs work git-svn-id: https://svn.eduke32.com/eduke32@976 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/astub.c | 19 +++-- polymer/eduke32/source/duke3d.h | 2 - polymer/eduke32/source/gamedef.c | 93 ++++++++++++++++--------- polymer/eduke32/source/gameexec.c | 13 ++-- polymer/eduke32/source/jmact/mathutil.c | 2 + polymer/eduke32/source/player.c | 2 +- 6 files changed, 85 insertions(+), 46 deletions(-) diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index f0bc961e9..2e5ff2014 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -1138,7 +1138,7 @@ int numhelppages=0; static int newpage(const char *start) { int i; - for (i=0; i<80; i++) + for (i=80-1; i>=0; i--) { // if (start[i]=='\n' || !start[i]) break; // if (start[i]!=' ' && start[i]!='\t' && start[i]!='\r') @@ -5394,8 +5394,18 @@ static void Keys3d(void) extern short brightness; keystatus[KEYSC_F11] = 0; - brightness++; - if (brightness >= 16) brightness = 0; + + if (eitherSHIFT) + { + brightness--; + if (brightness < 0) brightness = 15; + } + else + { + brightness++; + if (brightness >= 16) brightness = 0; + } + vid_gamma = 1.0 + ((float)brightness / 10.0); setbrightness(brightness,palette,0); message("Brightness: %d/16",brightness+1); @@ -5472,7 +5482,8 @@ static void Keys3d(void) if (keystatus[KEYSC_ENTER]) { extern char pskysearch[MAXSECTORS]; - short daang;int dashade[2]; + short daang; + int dashade[2]; if (eitherSHIFT) { if (((searchstat == 0) || (searchstat == 4)) && eitherCTRL) //Ctrl-shift Enter (auto-shade) diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index af09b0681..7e16609e7 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -143,8 +143,6 @@ enum gamemodes { #define MAXCYCLERS 1024 -#define MAXSCRIPTSIZE 131072 - #define MAXANIMATES 256 #define SP sprite[i].yvel diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 337bad162..9ee794417 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -898,6 +898,8 @@ const memberlabel_t inputlabels[]= { "", -1, 0, 0 } // END OF LIST }; +char *bitptr; + static int increasescriptsize(int size) { intptr_t oscriptptr = (unsigned)(scriptptr-script); @@ -909,7 +911,7 @@ static int increasescriptsize(int size) intptr_t i, j; int osize = g_ScriptSize; - for (i=0;i=0;i--) { if (labelcode[i] && labeltype[i] != LABEL_DEFINE) { @@ -918,33 +920,36 @@ static int increasescriptsize(int size) } scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(char)); - for (i=0;i=0;i--) { // initprintf("%d\n",i); - if ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize])) + if (bitptr[i] == 1 && !((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize]))) + initprintf("wtf\n"); + if (bitptr[i] == 0 && ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize]))) + initprintf("oh no!\n"); + if (bitptr[i] == 1 && ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize]))) { scriptptrs[i] = 1; - j = (intptr_t)script[i] - (intptr_t)&script[0]; - script[i] = j; + script[i] -= (intptr_t)&script[0]; } else scriptptrs[i] = 0; } - for (i=0;i=0;i--) + { if (actorscrptr[i]) { j = (intptr_t)actorscrptr[i]-(intptr_t)&script[0]; actorscrptr[i] = (intptr_t *)j; } - - for (i=0;i=0;i--) if (apScriptGameEvent[i]) { j = (intptr_t)apScriptGameEvent[i]-(intptr_t)&script[0]; @@ -953,8 +958,8 @@ 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); - newscript = (intptr_t *)Brealloc(script, g_ScriptSize * sizeof(intptr_t) * 2); + initprintf("Increasing script buffer size to %d bytes...\n",g_ScriptSize * sizeof(intptr_t)); + newscript = (intptr_t *)Brealloc(script, g_ScriptSize * sizeof(intptr_t)); if (newscript == NULL) { @@ -964,8 +969,15 @@ static int increasescriptsize(int size) error++; return 1; } +// Bmemset(&newscript[size],0,size); +// Bmemcpy(&newscript[size],&newscript[osize],osize); +// Bmemset(&newscript[osize],0,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)); if (casescriptptr != NULL) casescriptptr = (intptr_t *)(script+ocasescriptptr); @@ -974,7 +986,7 @@ static int increasescriptsize(int size) if (parsing_actor != NULL) parsing_actor = (intptr_t *)(script+oparsing_actor); - for (i=0;i=0;i--) { if (labelcode[i] && labeltype[i] != LABEL_DEFINE) { @@ -982,28 +994,28 @@ static int increasescriptsize(int size) } } - for (i=0;i=0;i--) if (scriptptrs[i]) { j = (intptr_t)script[i]+(intptr_t)&script[0]; script[i] = j; } - for (i=0;i=0;i--) + { if (actorscrptr[i]) { j = (intptr_t)actorscrptr[i]+(intptr_t)&script[0]; actorscrptr[i] = (intptr_t *)j; } - - for (i=0;i=0;i--) if (apScriptGameEvent[i]) { j = (intptr_t)apScriptGameEvent[i]+(intptr_t)&script[0]; @@ -1419,8 +1431,7 @@ static int transword(void) //Returns its code # { if (Bstrcmp(tempbuf,keyw[i]) == 0) { - *scriptptr = i; - script[scriptptr-script+g_ScriptSize] = line_number; + *scriptptr = i + (line_number<<12); textptr += l; scriptptr++; if (!(error || warning) && g_ScriptDebug) @@ -1638,6 +1649,8 @@ static int transnum(int type) initprintf("%s:%d: debug: accepted %s label `%s'.\n",compilefile,line_number,gl,label+(i<<6)); Bfree(gl); } + if (labeltype[i] != LABEL_DEFINE && labelcode[i] != 0) + bitptr[(scriptptr-script)] = 1; *(scriptptr++) = labelcode[i]; textptr += l; return labeltype[i]; @@ -1782,6 +1795,7 @@ static int parsecommand(void) if (!(error || warning) && g_ScriptDebug > 1) initprintf("%s:%d: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6)); *scriptptr = labelcode[j]; + bitptr[(scriptptr-script)] = 1; break; } else @@ -1986,7 +2000,7 @@ static int parsecommand(void) ReportError(ERROR_SYNTAXERROR); transnum(LABEL_DEFINE); transnum(LABEL_DEFINE); - scriptptr -= 3; // we complete the process anyways just to skip past the fucked up section + scriptptr -= 2; // we complete the process anyways just to skip past the fucked up section return 0; } getlabel(); @@ -2355,14 +2369,14 @@ static int parsecommand(void) getlabel(); // Check to see it's already defined - for (i=0;i=0;i--) if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) { error++; ReportError(ERROR_ISAKEYWORD); return 0; } - for (i=0;i=0;i--) if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_ACTION) */) { warning++; @@ -2370,7 +2384,7 @@ static int parsecommand(void) break; } - if (i == labelcnt) + if (i == -1) { labeltype[labelcnt] = LABEL_ACTION; labelcode[labelcnt] = (intptr_t) scriptptr; @@ -2725,6 +2739,7 @@ static int parsecommand(void) parsecommand(); tempscrptr = (intptr_t *)script+offset; *tempscrptr = (intptr_t) scriptptr; + bitptr[(tempscrptr-script)] = 1; } else { @@ -3752,6 +3767,7 @@ static int parsecommand(void) tempscrptr = (intptr_t *)script+offset; *tempscrptr = (intptr_t) scriptptr; + bitptr[(tempscrptr-script)] = 1; if (tw != CON_WHILEVARVARN) checking_ifelse++; return 0; @@ -3793,6 +3809,7 @@ static int parsecommand(void) tempscrptr = (intptr_t *)script+offset; *tempscrptr = (intptr_t) scriptptr; + bitptr[(tempscrptr-script)] = 1; if (tw != CON_WHILEVARN) checking_ifelse++; return 0; @@ -4049,6 +4066,7 @@ static int parsecommand(void) } // for (j=3;j<3+tempscrptr[1]*2;j+=2)initprintf("%5d %8x\n",tempscrptr[j],tempscrptr[j+1]); tempscrptr[0]= (intptr_t)scriptptr - (intptr_t)&script[0]; // save 'end' location +// bitptr[(tempscrptr-script)] = 1; } else { @@ -4157,6 +4175,7 @@ repeatcase: if (casescriptptr) { casescriptptr[0]=(intptr_t)(scriptptr-&script[0]); // save offset +// bitptr[(casescriptptr-script)] = 1; } //Bsprintf(g_szBuf,"default: '%.22s'",textptr); //AddLog(g_szBuf); @@ -4321,6 +4340,7 @@ repeatcase: parsecommand(); tempscrptr = (intptr_t *)script+offset; *tempscrptr = (intptr_t) scriptptr; + bitptr[(tempscrptr-script)] = 1; checking_ifelse++; return 0; @@ -4361,6 +4381,7 @@ repeatcase: case CON_DEFINEVOLUMENAME: scriptptr--; + transnum(LABEL_DEFINE); scriptptr--; j = *scriptptr; @@ -4434,6 +4455,7 @@ repeatcase: case CON_DEFINESKILLNAME: scriptptr--; + transnum(LABEL_DEFINE); scriptptr--; j = *scriptptr; @@ -4468,6 +4490,7 @@ repeatcase: { char gamename[32]; scriptptr--; + while (*textptr == ' ' || *textptr == '\t') textptr++; i = 0; @@ -4492,14 +4515,14 @@ repeatcase: return 0; case CON_DEFINEGAMETYPE: - scriptptr--; //remove opcode from compiled code - transnum(LABEL_DEFINE); //translate number - scriptptr--; //remove it from compiled code - j = *scriptptr; //put it into j + scriptptr--; + transnum(LABEL_DEFINE); + scriptptr--; + j = *scriptptr; - transnum(LABEL_DEFINE); //translate number - scriptptr--; //remove it from compiled code - gametype_flags[j] = *scriptptr; //put it into the flags + transnum(LABEL_DEFINE); + scriptptr--; + gametype_flags[j] = *scriptptr; while (*textptr == ' ' || *textptr == '\t') textptr++; @@ -4630,7 +4653,9 @@ repeatcase: case CON_DEFINEQUOTE: case CON_REDEFINEQUOTE: if (tw == CON_DEFINEQUOTE) + { scriptptr--; + } transnum(LABEL_DEFINE); @@ -5274,8 +5299,10 @@ void loadefs(const char *filenam) // clearbufbyte(script,sizeof(script),0l); // JBF 20040531: yes? no? if (script != NULL) Bfree(script); - script = Bcalloc(1,g_ScriptSize * sizeof(intptr_t) * 2); - clearbufbyte(&script[g_ScriptSize],g_ScriptSize * sizeof(intptr_t),0L); + + script = Bcalloc(1,g_ScriptSize * sizeof(intptr_t)); + bitptr = Bcalloc(1,g_ScriptSize * sizeof(char)); + initprintf("script: %d, bitptr: %d\n",script,bitptr); labelcnt = defaultlabelcnt = 0; scriptptr = script+1; @@ -5363,7 +5390,7 @@ void loadefs(const char *filenam) k++; } - initprintf("Compiled code size: %ld bytes, version %s\n",(unsigned)(scriptptr-script),(g_ScriptVersion == 14?"1.4+":"1.3D")); + 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); diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index db96a8f70..d20834f49 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -4504,8 +4504,8 @@ static int parse(void) // Bsprintf(g_szBuf,"Parsing: %d",*insptr); // AddLog(g_szBuf); - line_num = insptr[g_ScriptSize]; - g_tw = tw; + line_num = tw>>12; + g_tw = tw &= 0xFFF; switch (tw) { @@ -7529,7 +7529,7 @@ static int parse(void) j=GetGameVarID(*(insptr++), g_i, g_p); if (numplayers != 1 || !(g_player[myconnectindex].ps->gm & MODE_GAME)) { - OSD_Printf(CON_ERROR "CON_ACTIVATECHEAT: Not in a single-player game.\n"); + OSD_Printf(CON_ERROR "not in a single-player game.\n"); break; } osdcmd_cheatsinfo_stat.cheatnum = j; @@ -7699,12 +7699,12 @@ static int parse(void) if (g_player[g_p].ps->knee_incs == 0 && sprite[g_player[g_p].ps->i].xrepeat >= 40) if (cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,g_player[g_p].ps->posx,g_player[g_p].ps->posy,g_player[g_p].ps->posz+(16<<8),sprite[g_player[g_p].ps->i].sectnum)) { - for (j=0;j=0;j--) { if (g_player[j].ps->actorsqu == g_i) break; } - if (j == ud.multimode) + if (j == -1) { g_player[g_p].ps->knee_incs = 1; if (g_player[g_p].ps->weapon_pos == 0) @@ -7850,9 +7850,10 @@ static int parse(void) default: OSD_Printf("fatal error: default processing: previous five values: %d, %d, %d, %d, %d, " - "currrent opcode: %d, next five values: %d, %d, %d, %d, %d\ncurrent actor: %d (%d)\n", + "current opcode: %d, next five values: %d, %d, %d, %d, %d\ncurrent actor: %d (%d)\n", *(insptr-5),*(insptr-4),*(insptr-3),*(insptr-2),*(insptr-1),*insptr,*(insptr+1), *(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5),g_i,g_sp->picnum); + OSD_Printf("line_num: %d, g_tw: %d\n",line_num,g_tw); gameexit("An error has occurred in the EDuke32 CON executor.\n\n" "If you are an end user, please e-mail the file eduke32.log\n" diff --git a/polymer/eduke32/source/jmact/mathutil.c b/polymer/eduke32/source/jmact/mathutil.c index ca186cec7..3c96cb213 100644 --- a/polymer/eduke32/source/jmact/mathutil.c +++ b/polymer/eduke32/source/jmact/mathutil.c @@ -31,6 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ //------------------------------------------------------------------------- +#include +#include "compat.h" #include "pragmas.h" // I wonder if it's faster to use Ken's functions here... diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 311006cd3..67c8fec17 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -2753,7 +2753,7 @@ int jump_input = 0; void getinput(int snum) { int j, daang; - ControlInfo info; + static ControlInfo info; int32 tics; boolean running; int32 turnamount;