diff --git a/polymer/eduke32/a.m32 b/polymer/eduke32/a.m32 index 8460e5400..87323b521 100644 --- a/polymer/eduke32/a.m32 +++ b/polymer/eduke32/a.m32 @@ -3,10 +3,14 @@ include names.h -gamevar i 0 1 // per-block (top-level, event, or state) variable +// flag 1: per-block (top-level, event, or state) variable +gamevar i 0 1 gamevar j 0 1 gamevar k 0 1 gamevar l 0 1 +gamevar m 0 1 +gamevar p 0 1 +gamevar q 0 1 gamevar tmp 0 0 @@ -243,18 +247,6 @@ onevent EVENT_ENTER3DMODE state setas endevent -onevent EVENT_ANALYZESPRITES - for i drawnsprites - { - set j tsprite[i].owner - switch sprite[j].picnum - case LIZTROOP spritepal 1 break - case PIGCOP spritepal 2 break - case BOSS1 spritepal 6 break - endswitch - } -endevent - defstate cmp_by_lotag set RETURN sprite[SV2].lotag sub RETURN sprite[SV1].lotag @@ -290,7 +282,7 @@ onevent EVENT_DRAW2DSCREEN set drawlinepat -1 for i allsprites ifactor LIZTROOP - drawcircle16b sprite[i].x sprite[i].y 256 9 + drawcircle16b sprite[i].x sprite[i].y 256 drawcol */ endevent @@ -310,6 +302,73 @@ onevent EVENT_INSERTSPRITE2D } endevent +// rotates and duplicates selected sprites around +// pivot sprite (extra=123, ang:dang, yrepeat<<5:dz (pos. if pal!=0), lo:cnt) +defstate duprot + ifn searchstat 3 return + ifn sprite[searchwall].extra 123 return + ifl sprite[searchwall].shade 1 return + set k searchwall + + for i range sprite[k].shade + { + for j selsprites, ifn j k + { + dupsprite j + set tmp i, add tmp 1, mul tmp sprite[k].ang + rotatepoint sprite[k].x sprite[k].y .x .y tmp (l m) + add .ang tmp + set tmp i, add tmp 1, mul tmp sprite[k].yrepeat, shiftl tmp 5 + ife sprite[k].pal 0 inv tmp + add tmp .z + bsetsprite I l m tmp + } + } +ends + +// same as above but with tsprite[], as a kind of preview +defstate tduprot + ifn searchstat 3 return + ifn sprite[searchwall].extra 123 return + ifl sprite[searchwall].shade 1 return + set k searchwall + + for i range sprite[k].shade + { + for j selsprites, ifn j k + { + set p spritesortcnt + tdupsprite j + set tmp i, add tmp 1, mul tmp sprite[k].ang + rotatepoint sprite[k].x sprite[k].y tsprite[p].x tsprite[p].y tmp (l m) + add tsprite[p].ang tmp + set tmp i, add tmp 1, mul tmp sprite[k].yrepeat, shiftl tmp 5 + ife sprite[k].pal 0 inv tmp + add tmp tsprite[p].z + set tsprite[p].x l + set tsprite[p].y m + set tsprite[p].z tmp + or tsprite[p].cstat 514 +// bsetsprite I l m tmp + } + } +ends + +onevent EVENT_ANALYZESPRITES + state tduprot +/* + for i drawnsprites + { + set j tsprite[i].owner + switch sprite[j].picnum + case LIZTROOP spritepal 1 break + case PIGCOP spritepal 2 break + case BOSS1 spritepal 6 break + endswitch + } +*/ +endevent + onevent EVENT_KEYS3D // swinging doors tester -- hit space on a door wall ife searchstat 0 @@ -371,26 +430,33 @@ onevent EVENT_KEYS3D ife searchstat 3 ifhitkey KEY_SPACE { - ifn sprite[searchwall].picnum SECTOREFFECTOR return - set tmp 0 - ife sprite[searchwall].lotag 7 set tmp 1 - ife sprite[searchwall].lotag 17 set tmp 1 - ife tmp 0 return - - for i allsprites + ife sprite[searchwall].picnum SECTOREFFECTOR { - ifn i searchwall, ifactor SECTOREFFECTOR, ife sprite[i].lotag sprite[searchwall].lotag - ife sprite[i].hitag sprite[searchwall].hitag + set tmp 0 + ife sprite[searchwall].lotag 7 set tmp 1 + ife sprite[searchwall].lotag 17 set tmp 1 + ife tmp 0 return + + for i allsprites { - add posx sprite[i].x, sub posx sprite[searchwall].x - add posy sprite[i].y, sub posy sprite[searchwall].y - add posz sprite[i].z, sub posz sprite[searchwall].z + ifn i searchwall, ifactor SECTOREFFECTOR, ife sprite[i].lotag sprite[searchwall].lotag + ife sprite[i].hitag sprite[searchwall].hitag + { + add posx sprite[i].x, sub posx sprite[searchwall].x + add posy sprite[i].y, sub posy sprite[searchwall].y + add posz sprite[i].z, sub posz sprite[searchwall].z - updatecursectnum + updatecursectnum - return + return + } } } + else ife sprite[searchwall].extra 123 + { + state duprot + add sprite[searchwall].extra 1 + } } ifholdkey KEY_0 diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index ce1bb9a17..43c15b6e0 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -1380,6 +1380,8 @@ void OSD_Draw(void) // and write it to the log file // +extern int32_t premap_quickenterlevel; + static inline void linefeed(void) { Bmemmove(osdtext+osdcols, osdtext, TEXTSIZE-osdcols); @@ -1397,6 +1399,8 @@ void OSD_Printf(const char *fmt, ...) if (!osdinited) OSD_Init(); + if (premap_quickenterlevel) return; + va_start(va, fmt); Bvsnprintf(tmpstr, 8192, fmt, va); va_end(va); diff --git a/polymer/eduke32/m32script_ex.map b/polymer/eduke32/m32script_ex.map new file mode 100755 index 000000000..0d79ee674 Binary files /dev/null and b/polymer/eduke32/m32script_ex.map differ diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 66e7e5d1f..614e5b44d 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -78,6 +78,8 @@ static int16_t g_definedsndnum[MAXSOUNDS]; // maps parse order index to g_sound static int16_t g_sndnum[MAXSOUNDS]; // maps current order index to g_sounds index int32_t g_numsounds = 0; +int32_t premap_quickenterlevel=0; + #if !defined(_WIN32) static int32_t usecwd = 0; #endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index f12d036a3..a3db560e0 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -8116,6 +8116,8 @@ static void G_ShowScores(void) #undef SCORESHEETOFFSET +static int32_t demo_goalreccnt=0, demo_startreccnt=0, demo_oldsoundtoggle, demo_showstats=1; + static void G_HandleLocalKeys(void) { int32_t i,ch; @@ -8235,6 +8237,78 @@ static void G_HandleLocalKeys(void) P_DoQuote(83+ud.scrollmode,g_player[myconnectindex].ps); } + if (ud.recstat == 2) + { + if (KB_KeyPressed(sc_Tab)) + { + KB_ClearKeyDown(sc_Tab); + demo_showstats = !demo_showstats; + } + + if (KB_KeyPressed(sc_kpad_Plus)) + { + if (g_timerTicsPerSecond != 240) + { + uninittimer(); + inittimer(240); + g_timerTicsPerSecond = 240; + } + } + else if (KB_KeyPressed(sc_kpad_Minus)) + { + if (g_timerTicsPerSecond != 60) + { + uninittimer(); + inittimer(60); + g_timerTicsPerSecond = 60; + } + } + else if (g_timerTicsPerSecond != 120) + { + uninittimer(); + inittimer(120); + g_timerTicsPerSecond = 120; + } + + if (KB_KeyPressed(sc_kpad_6)) + { + KB_ClearKeyDown(sc_kpad_6); + j = ALT_IS_PRESSED ? 30 : 10; + demo_goalreccnt = ud.reccnt-(TICRATE/TICSPERFRAME)*ud.multimode*j; + demo_oldsoundtoggle = ud.config.SoundToggle; + + j=(demo_startreccnt-ud.reccnt)/(ud.multimode*(TICRATE/TICSPERFRAME)); + OSD_Printf(" FF %d s from %02d:%02d\n", ALT_IS_PRESSED ? 30 : 10, j/60, j%60); + + if (demo_goalreccnt <= 0) + demo_goalreccnt = 0; + else + { + ud.config.SoundToggle = 0; + FX_StopAllSounds(); + S_ClearSoundLocks(); + } + } + else if (KB_KeyPressed(sc_kpad_4)) + { + KB_ClearKeyDown(sc_kpad_4); + j = ALT_IS_PRESSED ? 30 : 10; + demo_goalreccnt = ud.reccnt+(TICRATE/(TICRATE/GAMETICSPERSEC))*ud.multimode*j; + demo_oldsoundtoggle = ud.config.SoundToggle; + + j=(demo_startreccnt-ud.reccnt)/(ud.multimode*TICRATE/(TICRATE/GAMETICSPERSEC)); + OSD_Printf(" RW %d s from %02d:%02d\n", ALT_IS_PRESSED ? 30 : 10, j/60, j%60); + + if (demo_goalreccnt > demo_startreccnt) + demo_goalreccnt = demo_startreccnt; + + demo_goalreccnt = -demo_goalreccnt; + ud.config.SoundToggle = 0; + FX_StopAllSounds(); + S_ClearSoundLocks(); + } + } + if (SHIFTS_IS_PRESSED || ALT_IS_PRESSED) { i = 0; @@ -11384,6 +11458,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine } i = ud.reccnt/((TICRATE/TICSPERFRAME)*ud.multimode); OSD_Printf("demo duration: %d min %d sec\n", i/60, i%60); + demo_startreccnt = ud.reccnt; ud.god = ud.cashman = ud.eog = ud.showallmap = 0; ud.clipping = ud.scrollmode = ud.overhead_on = ud.pause_on = 0; @@ -11483,6 +11558,7 @@ void G_CloseDemoWrite(void) } static int32_t g_whichDemo = 1; +extern int32_t premap_quickenterlevel; // extern int32_t syncs[]; static int32_t G_PlaybackDemo(void) @@ -11501,14 +11577,13 @@ RECHECK: pus = NUMPAGES; flushperms(); - if (ud.multimode < 2) foundemo = G_OpenDemoRead(g_whichDemo); - if (foundemo == 0) { if (g_whichDemo > 1) { g_whichDemo = 1; + premap_quickenterlevel=0; goto RECHECK; } fadepal(0,0,0, 0,63,7); @@ -11525,14 +11600,18 @@ RECHECK: ud.recstat = 2; g_whichDemo++; if (g_whichDemo == 10) g_whichDemo = 1; + if (G_EnterLevel(MODE_DEMO)) ud.recstat = foundemo = 0; } - if (foundemo == 0 || in_menu || KB_KeyWaiting() || numplayers > 1) + if (!premap_quickenterlevel) { - FX_StopAllSounds(); - S_ClearSoundLocks(); - g_player[myconnectindex].ps->gm |= MODE_MENU; + if (foundemo == 0 || in_menu || KB_KeyWaiting() || numplayers > 1) + { + FX_StopAllSounds(); + S_ClearSoundLocks(); + g_player[myconnectindex].ps->gm |= MODE_MENU; + } } ready2send = 0; @@ -11545,7 +11624,9 @@ RECHECK: while (ud.reccnt > 0 || foundemo == 0) { if (foundemo) - while (totalclock >= (lockclock+TICSPERFRAME)) + { + while (totalclock >= (lockclock+TICSPERFRAME) || + (demo_goalreccnt>0 && demo_goalreccnt= RECSYNCBUFSIZ)) { @@ -11571,8 +11652,35 @@ RECHECK: } G_DoMoveThings(); ototalclock += TICSPERFRAME; + + if (demo_goalreccnt > 0) + { + if (demo_goalreccnt 1) // load the same demo again and FF from beginning... yay! + g_whichDemo--; + foundemo = 0; + ud.reccnt = 0; + kclose(recfilep); + premap_quickenterlevel=1; + goto RECHECK; + } + } + if (demo_goalreccnt > 0 && ud.reccnt<=demo_goalreccnt) + { + demo_goalreccnt = 0; + ud.config.SoundToggle = demo_oldsoundtoggle; + premap_quickenterlevel = 0; + } + } + if (foundemo == 0) G_DrawBackground(); else @@ -11584,6 +11692,13 @@ RECHECK: G_DrawRooms(screenpeek,j); G_DisplayRest(j); + if (demo_showstats && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) + { + j=(demo_startreccnt-ud.reccnt)/(TICRATE/TICSPERFRAME); + Bsprintf(buf, "%02d:%02d", j/60, j%60); + gametext(18,16,buf,0,2+8+16); + } + if (ud.multimode > 1 && g_player[myconnectindex].ps->gm) Net_GetPackets(); diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index b7aaecc41..157289ecf 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -310,6 +310,7 @@ const char *keyw[] = "resetkey", "insertsprite", "dupsprite", + "tdupsprite", "deletesprite", "lastwall", "updatecursectnum", @@ -2183,8 +2184,7 @@ repeatcase: if ((tw==CON_GETTSPR || tw==CON_SETTSPR) && cs.currentEvent != EVENT_ANALYZESPRITES) { - C_ReportError(-1); - initprintf("%s:%d: warning: found `%s' outside of EVENT_ANALYZESPRITES\n",g_szScriptFileName,g_lineNumber,tempbuf); + C_ReportError(WARNING_OUTSIDEDRAWSPRITE); g_numCompilerWarnings++; } @@ -2733,6 +2733,12 @@ repeatcase: } // *** BUILD functions + case CON_TDUPSPRITE: + if (cs.currentEvent>=0 && cs.currentEvent != EVENT_ANALYZESPRITES) + { + C_ReportError(WARNING_OUTSIDEDRAWSPRITE); + g_numCompilerWarnings++; + } case CON_RESETKEY: case CON_INSERTSPRITE: case CON_DUPSPRITE: @@ -3568,5 +3574,9 @@ void C_ReportError(int32_t iError) initprintf("%s:%d: warning: constants where gamevars are expected save only 16 bits.\n", g_szScriptFileName,g_lineNumber); break; + case WARNING_OUTSIDEDRAWSPRITE: + initprintf("%s:%d: warning: found `%s' outside of EVENT_ANALYZESPRITES\n", + g_szScriptFileName,g_lineNumber,tempbuf); + break; } } diff --git a/polymer/eduke32/source/m32def.h b/polymer/eduke32/source/m32def.h index b9f0049ae..df061d8c2 100644 --- a/polymer/eduke32/source/m32def.h +++ b/polymer/eduke32/source/m32def.h @@ -137,6 +137,7 @@ enum ScriptError_t WARNING_LABELSONLY, WARNING_NAMEMATCHESVAR, WARNING_CONSTANTBITSIZE, + WARNING_OUTSIDEDRAWSPRITE, }; @@ -390,6 +391,7 @@ enum ScriptKeywords_t CON_RESETKEY, CON_INSERTSPRITE, CON_DUPSPRITE, + CON_TDUPSPRITE, CON_DELETESPRITE, CON_LASTWALL, CON_UPDATECURSECTNUM, diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index 50ddf5821..50892feb2 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -1524,6 +1524,7 @@ badindex: continue; case CON_DUPSPRITE: + case CON_TDUPSPRITE: insptr++; { int32_t ospritenum = Gv_GetVarX(*insptr++), nspritenum; @@ -1533,26 +1534,38 @@ badindex: OSD_Printf(CON_ERROR "Tried to duplicate nonexistent sprite %d\n",g_errorLineNum,keyw[g_tw],ospritenum); vm.flags |= VMFLAG_ERROR; } - if (numsprites >= MAXSPRITES) + if ((tw==CON_DUPSPRITE && numsprites >= MAXSPRITES) || + (tw==CON_DUPSPRITE && spritesortcnt >= MAXSPRITESONSCREEN)) { OSD_Printf(CON_ERROR "Maximum number of sprites reached.\n",g_errorLineNum,keyw[g_tw]); vm.flags |= VMFLAG_ERROR; } if (vm.flags&VMFLAG_ERROR) continue; - nspritenum = insertsprite(sprite[ospritenum].sectnum, sprite[ospritenum].statnum); - - if (nspritenum < 0) + if (tw==CON_DUPSPRITE) { - OSD_Printf(CON_ERROR "Internal error.\n",g_errorLineNum,keyw[g_tw]); - vm.flags |= VMFLAG_ERROR; - continue; - } + nspritenum = insertsprite(sprite[ospritenum].sectnum, sprite[ospritenum].statnum); - Bmemcpy(&sprite[nspritenum], &sprite[ospritenum], sizeof(spritetype)); - vm.g_i = nspritenum; - vm.g_sp = &sprite[nspritenum]; - numsprites++; + if (nspritenum < 0) + { + OSD_Printf(CON_ERROR "Internal error.\n",g_errorLineNum,keyw[g_tw]); + vm.flags |= VMFLAG_ERROR; + continue; + } + + Bmemcpy(&sprite[nspritenum], &sprite[ospritenum], sizeof(spritetype)); + vm.g_i = nspritenum; + vm.g_sp = &sprite[nspritenum]; + numsprites++; + } + else + { + Bmemcpy(&tsprite[spritesortcnt], &sprite[ospritenum], sizeof(spritetype)); + tsprite[spritesortcnt].owner = ospritenum; + vm.g_i = -1; + vm.g_sp = &tsprite[spritesortcnt]; + spritesortcnt++; + } } continue; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 90ffc7ed8..29907f0e3 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1204,11 +1204,16 @@ static inline void prelevel(char g) } } +int32_t premap_quickenterlevel=0; + void G_NewGame(int32_t vn,int32_t ln,int32_t sk) { DukePlayer_t *p = g_player[0].ps; int32_t i; + if (!premap_quickenterlevel) + goto quick; + handleevents(); Net_GetPackets(); @@ -1250,6 +1255,7 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk) FX_StopAllSounds(); } +quick: g_showShareware = GAMETICSPERSEC*34; ud.level_number = ln; @@ -1653,7 +1659,6 @@ int32_t G_EnterLevel(int32_t g) // flushpackets(); // waitforeverybody(); - vote_map = vote_episode = voting = -1; if ((g&MODE_DEMO) != MODE_DEMO) ud.recstat = ud.m_recstat; @@ -1674,7 +1679,6 @@ int32_t G_EnterLevel(int32_t g) FX_SetReverb(0); setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP); - if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) { int32_t volume, level; @@ -1713,11 +1717,15 @@ int32_t G_EnterLevel(int32_t g) } } - i = ud.screen_size; - ud.screen_size = 0; - G_DoLoadScreen(NULL, -1); - G_UpdateScreenArea(); - ud.screen_size = i; + if (!premap_quickenterlevel) + { + i = ud.screen_size; + ud.screen_size = 0; + + G_DoLoadScreen(NULL, -1); + G_UpdateScreenArea(); + ud.screen_size = i; + } if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) { @@ -1728,7 +1736,6 @@ int32_t G_EnterLevel(int32_t g) Bstrcpy(tempbuf,apptitle); wm_setapptitle(tempbuf); - if (!VOLUMEONE) { if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) @@ -1856,9 +1863,12 @@ int32_t G_EnterLevel(int32_t g) } } - g_precacheCount = 0; - clearbufbyte(gotpic,sizeof(gotpic),0L); - clearbufbyte(precachehightile, sizeof(precachehightile), 0l); + if (!premap_quickenterlevel) + { + g_precacheCount = 0; + clearbufbyte(gotpic,sizeof(gotpic),0L); + clearbufbyte(precachehightile, sizeof(precachehightile), 0l); + } //clearbufbyte(ActorExtra,sizeof(ActorExtra),0l); // JBF 20040531: yes? no? prelevel(g); @@ -1869,7 +1879,8 @@ int32_t G_EnterLevel(int32_t g) cachedebug = 0; automapping = 0; - G_CacheMapData(); + if (!premap_quickenterlevel) + G_CacheMapData(); if (ud.recstat != 2) { @@ -1919,10 +1930,13 @@ int32_t G_EnterLevel(int32_t g) //g_player[myconnectindex].ps->palette = palette; //G_FadePalette(0,0,0,0); - P_SetGamePalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 + if (!premap_quickenterlevel) + { + P_SetGamePalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 - P_UpdateScreenPal(g_player[myconnectindex].ps); - flushperms(); + P_UpdateScreenPal(g_player[myconnectindex].ps); + flushperms(); + } everyothertime = 0; g_globalRandom = 0; @@ -1935,14 +1949,17 @@ int32_t G_EnterLevel(int32_t g) g_restorePalette = 1; - Net_WaitForEverybody(); - mmulti_flushpackets(); + if (!premap_quickenterlevel) + { + Net_WaitForEverybody(); + mmulti_flushpackets(); - G_FadePalette(0,0,0,0); - G_UpdateScreenArea(); - clearview(0L); - G_DrawBackground(); - G_DrawRooms(myconnectindex,65536); + G_FadePalette(0,0,0,0); + G_UpdateScreenArea(); + clearview(0L); + G_DrawBackground(); + G_DrawRooms(myconnectindex,65536); + } for (i=0; i