From 512535c53f6f32ff1714c272ddef0ff59e727e5b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 13 Feb 2010 21:46:42 +0000 Subject: [PATCH] EDuke32: new demo system should be stable now; Made the $EDUKE32_MUSIC_CMD env var work (SDL only). Mapster32: Helper feature -- pressing SHIFT on a 2-sided wall makes the PGUP/PGDN etc. commands operate on the sector at the other end of the wall; replaced searchstat numbers by #defined names and eliminated the worst cases of code duplication in astub.c git-svn-id: https://svn.eduke32.com/eduke32@1598 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 44 +- polymer/eduke32/source/astub.c | 942 ++++++++++------------------- polymer/eduke32/source/game.c | 53 +- polymer/eduke32/source/menus.c | 2 +- polymer/eduke32/source/savegame.c | 26 +- polymer/eduke32/source/sdlmusic.c | 45 +- polymer/eduke32/source/sounds.c | 2 +- 7 files changed, 422 insertions(+), 692 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 5a9810273..3ecad98fe 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -9504,53 +9504,49 @@ void getmousevalues(int32_t *mousx, int32_t *mousy, int32_t *bstatus) # include # define KRD_MAXCALLS 262144 # define KRD_DEPTH 8 -static int krd_numcalls=0; -static int krd_randomseed[KRD_MAXCALLS]; -static int krd_totalclock[KRD_MAXCALLS]; +static int32_t krd_numcalls=0; static void *krd_fromwhere[KRD_MAXCALLS][KRD_DEPTH]; static int32_t krd_enabled=0; -void krd_enable() +void krd_enable(int which) // 0: disable, 1: rec, 2: play { - krd_enabled = 1; + krd_enabled = which; + + if (which) + Bmemset(krd_fromwhere, 0, sizeof(krd_fromwhere)); } int32_t krd_print(const char *filename) { - FILE *krd_fp = fopen(filename, "w"); - int i, j, k, ototalclk=0; + FILE *fp; + int32_t i, j; + if (!krd_enabled) return 1; krd_enabled = 0; - if (!krd_fp) { printf("KRANDDEBUG: Couldn't open file!"); return 1; } + + fp = fopen(filename, "wb"); + if (!fp) { OSD_Printf("krd_print (2): fopen"); return 1; } for (i=0; i=KRD_DEPTH || krd_fromwhere[i][j]==NULL) { - fprintf(krd_fp, "\n"); + fprintf(fp, "\n"); break; } - fprintf(krd_fp, " [%p]", krd_fromwhere[i][j]); + fprintf(fp, " [%p]", krd_fromwhere[i][j]); } } krd_numcalls = 0; - fclose(krd_fp); + fclose(fp); return 0; } -#endif +#endif // KRANDDEBUG + // // krand @@ -9564,11 +9560,7 @@ int32_t krand(void) if (krd_enabled) if (krd_numcalls < KRD_MAXCALLS) { - int32_t i; - krd_randomseed[krd_numcalls] = randomseed; - krd_totalclock[krd_numcalls] = totalclock; - for (i=backtrace(krd_fromwhere[krd_numcalls],KRD_DEPTH); ix - s1->x))*((int64_t)(s2->x - s1->x)) + ((int64_t)(s2->y - s1->y))*((int64_t)(s2->y - s1->y))); } +#endif -void rendertext(int16_t startspr) +static void TextEntryMode(int16_t startspr) { char ch, buffer[80], doingspace=0; int16_t daang = 0, t, alphidx, basetile, linebegspr, curspr, cursor; @@ -4323,7 +4331,7 @@ static void Keys3d(void) if (usedcount && !helpon) { - if (searchstat!=3) + if (searchstat!=SEARCH_SPRITE) { count=0; for (i=0; i= 0) @@ -4569,13 +4577,13 @@ static void Keys3d(void) keystatus[KEYSC_DELETE] = 0; switch (searchstat) { - case 0: - case 4: + case SEARCH_WALL: + case SEARCH_MASKWALL: wall[searchwall].cstat = 0; message("Wall %d cstat = 0",searchwall); break; // case 1: case 2: sector[searchsector].cstat = 0; break; - case 3: + case SEARCH_SPRITE: sprite[searchwall].cstat = 0; message("Sprite %d cstat = 0",searchwall); break; @@ -4678,7 +4686,7 @@ static void Keys3d(void) if (keystatus[KEYSC_DELETE]) { - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { deletesprite(searchwall); updatenumsprites(); @@ -4706,17 +4714,17 @@ static void Keys3d(void) message("Automatic sector tag help %s",autosecthelp?"enabled":"disabled"); } - if ((searchstat == 3) && (sprite[searchwall].picnum==SECTOREFFECTOR)) + if ((searchstat == SEARCH_SPRITE) && (sprite[searchwall].picnum==SECTOREFFECTOR)) if (autospritehelp && helpon==0) Show3dText("sehelp.hlp"); - if (searchstat == 1 || searchstat == 2) + if (searchstat == SEARCH_CEILING || searchstat == SEARCH_FLOOR) if (autosecthelp && helpon==0) Show3dText("sthelp.hlp"); if (keystatus[KEYSC_COMMA]) // , Search & fix panning to the left (3D) { - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { i = searchwall; if (eitherSHIFT) @@ -4731,13 +4739,13 @@ static void Keys3d(void) } if (keystatus[KEYSC_PERIOD]) // . Search & fix panning to the right (3D) { - if ((searchstat == 0) || (searchstat == 4)) + if ((searchstat == SEARCH_WALL) || (searchstat == SEARCH_MASKWALL)) { AutoAlignWalls((int32_t)searchwall,0L); message("Wall %d autoalign",searchwall); keystatus[KEYSC_PERIOD] = 0; } - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { i = searchwall; if (eitherSHIFT) @@ -4757,7 +4765,7 @@ static void Keys3d(void) noclip = 1; switch (searchstat) { - case 1: + case SEARCH_CEILING: getnumberptr256("Sector ceilingz: ",§or[searchsector].ceilingz,sizeof(sector[searchsector].ceilingz),8388608,1,NULL); if (!(sector[searchsector].ceilingstat&2)) { @@ -4766,7 +4774,7 @@ static void Keys3d(void) } getnumberptr256("Sector ceiling slope: ",§or[searchsector].ceilingheinum,sizeof(sector[searchsector].ceilingheinum),65536,1,NULL); break; - case 2: + case SEARCH_FLOOR: getnumberptr256("Sector floorz: ",§or[searchsector].floorz,sizeof(sector[searchsector].floorz),8388608,1,NULL); if (!(sector[searchsector].floorstat&2)) { @@ -4775,7 +4783,7 @@ static void Keys3d(void) } getnumberptr256("Sector floor slope: ",§or[searchsector].floorheinum,sizeof(sector[searchsector].floorheinum),65536,1,NULL); break; - case 3: + case SEARCH_SPRITE: getnumberptr256("Sprite x: ",&sprite[searchwall].x,sizeof(sprite[searchwall].x),131072,1,NULL); getnumberptr256("Sprite y: ",&sprite[searchwall].y,sizeof(sprite[searchwall].y),131072,1,NULL); getnumberptr256("Sprite z: ",&sprite[searchwall].z,sizeof(sprite[searchwall].z),8388608,1,NULL); @@ -4816,17 +4824,17 @@ static void Keys3d(void) { switch (searchstat) { - case 0: - case 4: + case SEARCH_WALL: + case SEARCH_MASKWALL: strcpy(buffer,"Wall extra: "); wall[searchwall].extra = getnumber256(buffer,(int32_t)wall[searchwall].extra,65536L,1); break; - case 1: - case 2: + case SEARCH_CEILING: + case SEARCH_FLOOR: strcpy(buffer,"Sector extra: "); sector[searchsector].extra = getnumber256(buffer,(int32_t)sector[searchsector].extra,65536L,1); break; - case 3: + case SEARCH_SPRITE: // strcpy(buffer,"Sprite extra: "); // sprite[searchwall].extra = getnumber256(buffer,(int32_t)sprite[searchwall].extra,65536L,1); getnumberptr256("Sprite extra: ",&sprite[searchwall].extra,sizeof(sprite[searchwall].extra),1024,1,NULL); @@ -4838,7 +4846,7 @@ static void Keys3d(void) if (keystatus[KEYSC_1]) // 1 (make 1-way wall) { - if (searchstat != 3) + if (searchstat != SEARCH_SPRITE) { wall[searchwall].cstat ^= 32; Bsprintf(getmessage,"Wall %d one side masking bit %s",searchwall,wall[searchwall].cstat&32?"ON":"OFF"); @@ -4865,7 +4873,7 @@ static void Keys3d(void) } if (keystatus[KEYSC_2]) // 2 (bottom wall swapping) { - if (searchstat != 3) + if (searchstat != SEARCH_SPRITE) { wall[searchwall].cstat ^= 2; Bsprintf(getmessage,"Wall %d bottom texture swap bit %s",searchwall,wall[searchwall].cstat&2?"ON":"OFF"); @@ -4876,15 +4884,15 @@ static void Keys3d(void) } if (keystatus[KEYSC_O]) // O (top/bottom orientation - for doors) { - if ((searchstat == 0) || (searchstat == 4)) + if ((searchstat == SEARCH_WALL) || (searchstat == SEARCH_MASKWALL)) { - int16_t w = (searchstat==0)?searchbottomwall:searchwall; + int16_t w = (searchstat==SEARCH_WALL)?searchbottomwall:searchwall; wall[w].cstat ^= 4; Bsprintf(getmessage,"Wall %d %s orientation",w,wall[w].cstat&4?"bottom":"top"); message(getmessage); asksave = 1; } - if (searchstat == 3) // O (ornament onto wall) (2D) + if (searchstat == SEARCH_SPRITE) // O (ornament onto wall) (2D) { asksave = 1; i = searchwall; @@ -4897,7 +4905,7 @@ static void Keys3d(void) } if (keystatus[KEYSC_M]) // M (masking walls) { - if (searchstat != 3) + if (searchstat != SEARCH_SPRITE) { i = wall[searchwall].nextwall; tempint = eitherSHIFT; @@ -4939,20 +4947,17 @@ static void Keys3d(void) { switch (searchstat) { - case 0: - case 4: + case SEARCH_WALL: + case SEARCH_MASKWALL: strcpy(buffer,"Wall hitag: "); wall[searchwall].hitag = getnumber256(buffer,(int32_t)wall[searchwall].hitag,65536L,0); break; - case 1: + case SEARCH_CEILING: + case SEARCH_FLOOR: strcpy(buffer,"Sector hitag: "); sector[searchsector].hitag = getnumber256(buffer,(int32_t)sector[searchsector].hitag,65536L,0); break; - case 2: - strcpy(buffer,"Sector hitag: "); - sector[searchsector].hitag = getnumber256(buffer,(int32_t)sector[searchsector].hitag,65536L,0); - break; - case 3: + case SEARCH_SPRITE: strcpy(buffer,"Sprite hitag: "); // sprite[searchwall].hitag = getnumber256(buffer,(int32_t)sprite[searchwall].hitag,65536L,0); getnumberptr256(buffer,&sprite[searchwall].hitag,sizeof(sprite[searchwall].hitag),INT16_MAX,1,NULL); @@ -4963,7 +4968,7 @@ static void Keys3d(void) else { - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { sprite[searchwall].cstat ^= 256; Bsprintf(getmessage,"Sprite %d hitscan sensitivity bit %s",searchwall,sprite[searchwall].cstat&256?"ON":"OFF"); @@ -5003,113 +5008,27 @@ static void Keys3d(void) // { // mlook = 2; // } + tsign = 0; if (bstatus&32 || keystatus[KEYSC_gMINUS]) // - - { - keystatus[KEYSC_gMINUS]=0; - mouseb &= ~32; - bstatus &= ~32; - if (eitherALT) //ALT - { - if (eitherCTRL) //CTRL - { - if (visibility < 16384) visibility += visibility; - Bsprintf(getmessage,"Global visibility %d",visibility); - message(getmessage); - } - else - { - k=eitherSHIFT?1:16; - - if (highlightsectorcnt >= 0) - for (i=0; i 0) - { - for (i=0; i 0) - { - sector[searchsector].visibility++; - if (sector[searchsector].visibility == 240) - sector[searchsector].visibility = 239; - k--; - } - Bsprintf(getmessage,"Sector %d visibility %d",searchsector,sector[searchsector].visibility); - message(getmessage); - asksave = 1; - } - } - else - { - k = 0; - if (highlightsectorcnt >= 0) - { - for (i=0; i 32) visibility >>= 1; + if (tsign==1) + { + if (visibility < 16384) visibility += visibility; + } + else + if (visibility > 32) visibility >>= 1; Bsprintf(getmessage,"Global visibility %d",visibility); message(getmessage); } @@ -5125,9 +5044,15 @@ static void Keys3d(void) { for (i=0; i 0) { - sector[searchsector].visibility--; - if (sector[searchsector].visibility == 239) - sector[searchsector].visibility = 240; + sector[searchsector].visibility += tsign; + if (tsign==1) + { + if (sector[searchsector].visibility == 240) + sector[searchsector].visibility = 239; + } + else + if (sector[searchsector].visibility == 239) + sector[searchsector].visibility = 240; k--; } Bsprintf(getmessage,"Sector %d visibility %d",searchsector,sector[searchsector].visibility); @@ -5161,11 +5092,11 @@ static void Keys3d(void) if (k == 0) { int32_t shade=-1, i=-1; - if (searchstat == 0) shade=--wall[i=searchbottomwall].shade; - if (searchstat == 1) shade=--sector[i=searchsector].ceilingshade; - if (searchstat == 2) shade=--sector[i=searchsector].floorshade; - if (searchstat == 3) shade=--sprite[i=searchwall].shade; - if (searchstat == 4) shade=--wall[i=searchwall].shade; + if (searchstat == SEARCH_WALL) shade = (wall[i=searchbottomwall].shade += tsign); + if (searchstat == SEARCH_CEILING) shade = (sector[i=searchsector].ceilingshade += tsign); + if (searchstat == SEARCH_FLOOR) shade = (sector[i=searchsector].floorshade += tsign); + if (searchstat == SEARCH_SPRITE) shade = (sprite[i=searchwall].shade += tsign); + if (searchstat == SEARCH_MASKWALL) shade = (wall[i=searchwall].shade += tsign); if (i!=-1) { Bsprintf(getmessage,"%s %d shade %d",type2str[searchstat],i,shade); @@ -5178,18 +5109,18 @@ static void Keys3d(void) { dasector = highlightsector[i]; - sector[dasector].ceilingshade--; //sector shade - sector[dasector].floorshade--; + sector[dasector].ceilingshade += tsign; //sector shade + sector[dasector].floorshade += tsign; startwall = sector[dasector].wallptr; //wall shade endwall = startwall + sector[dasector].wallnum - 1; for (j=startwall; j<=endwall; j++) - wall[j].shade--; + wall[j].shade += tsign; j = headspritesect[dasector]; //sprite shade while (j != -1) { - sprite[j].shade--; + sprite[j].shade += tsign; j = nextspritesect[j]; } } @@ -5201,12 +5132,11 @@ static void Keys3d(void) // if ((keystatus[KEYSC_DASH]|keystatus[KEYSC_EQUAL]|((bstatus&(16|32)) && !(bstatus&2))) > 0) // mousewheel, -, and +, cycle picnum if (keystatus[KEYSC_DASH] | keystatus[KEYSC_EQUAL] | (bstatus&(16|32) && (bstatus&1) && !(bstatus&2))) // PK: lmb only & mousewheel, -, and +, cycle picnum - { j = i = (keystatus[KEYSC_EQUAL] || (bstatus&16))?1:-1; switch (searchstat) { - case 0: + case SEARCH_WALL: while (!tilesizx[wall[searchwall].picnum]||!tilesizy[wall[searchwall].picnum]||j) { if (wall[searchwall].picnum+i >= MAXTILES) wall[searchwall].picnum = 0; @@ -5215,7 +5145,7 @@ static void Keys3d(void) j = 0; } break; - case 1: + case SEARCH_CEILING: while (!tilesizx[sector[searchsector].ceilingpicnum]||!tilesizy[sector[searchsector].ceilingpicnum]||j) { if (sector[searchsector].ceilingpicnum+i >= MAXTILES) sector[searchsector].ceilingpicnum = 0; @@ -5224,7 +5154,7 @@ static void Keys3d(void) j = 0; } break; - case 2: + case SEARCH_FLOOR: while (!tilesizx[sector[searchsector].floorpicnum]||!tilesizy[sector[searchsector].floorpicnum]||j) { if (sector[searchsector].floorpicnum+i >= MAXTILES) sector[searchsector].floorpicnum = 0; @@ -5233,7 +5163,7 @@ static void Keys3d(void) j = 0; } break; - case 3: + case SEARCH_SPRITE: while (!tilesizx[sprite[searchwall].picnum]||!tilesizy[sprite[searchwall].picnum]||j) { if (sprite[searchwall].picnum+i >= MAXTILES) sprite[searchwall].picnum = 0; @@ -5242,7 +5172,7 @@ static void Keys3d(void) j = 0; } break; - case 4: + case SEARCH_MASKWALL: while (!tilesizx[wall[searchwall].overpicnum]||!tilesizy[wall[searchwall].overpicnum]||j) { if (wall[searchwall].overpicnum+i >= MAXTILES) wall[searchwall].overpicnum = 0; @@ -5259,14 +5189,14 @@ static void Keys3d(void) if (keystatus[KEYSC_E]) // E (expand) { - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { sector[searchsector].ceilingstat ^= 8; Bsprintf(getmessage,"Sector %d ceiling texture expansion bit %s",searchsector,sector[searchsector].ceilingstat&8?"ON":"OFF"); message(getmessage); asksave = 1; } - if (searchstat == 2) + if (searchstat == SEARCH_FLOOR) { sector[searchsector].floorstat ^= 8; Bsprintf(getmessage,"Sector %d floor texture expansion bit %s",searchsector,sector[searchsector].floorstat&8?"ON":"OFF"); @@ -5277,34 +5207,29 @@ static void Keys3d(void) } if (keystatus[KEYSC_R]) // R (relative alignment, rotation) { - if (keystatus[KEYSC_QUOTE]) // FRAMERATE TOGGLE { - framerateon = !framerateon; if (framerateon) message("Show framerate ON"); else message("Show framerate OFF"); - } - else - { - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { sector[searchsector].ceilingstat ^= 64; Bsprintf(getmessage,"Sector %d ceiling texture relativity bit %s",searchsector,sector[searchsector].ceilingstat&64?"ON":"OFF"); message(getmessage); asksave = 1; } - if (searchstat == 2) + if (searchstat == SEARCH_FLOOR) { sector[searchsector].floorstat ^= 64; Bsprintf(getmessage,"Sector %d floor texture relativity bit %s",searchsector,sector[searchsector].floorstat&64?"ON":"OFF"); //PK (was ceiling in string) message(getmessage); asksave = 1; } - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { i = sprite[searchwall].cstat; if ((i&48) < 32) i += 16; @@ -5329,7 +5254,7 @@ static void Keys3d(void) keystatus[KEYSC_F] = 0; if (eitherALT) //ALT-F (relative alignmment flip) { - if (searchstat != 3) + if (searchstat != SEARCH_SPRITE) { setfirstwall(searchsector,searchwall); Bsprintf(getmessage,"Sector %d first wall",searchsector); @@ -5339,7 +5264,7 @@ static void Keys3d(void) } else { - if ((searchstat == 0) || (searchstat == 4)) + if ((searchstat == SEARCH_WALL) || (searchstat == SEARCH_MASKWALL)) { i = wall[searchbottomwall].cstat; i = ((i>>3)&1)+((i>>7)&2); //3-x,8-y @@ -5365,7 +5290,7 @@ static void Keys3d(void) wall[searchbottomwall].cstat |= i; asksave = 1; } - if (searchstat == 1) //8-way ceiling flipping (bits 2,4,5) + if (searchstat == SEARCH_CEILING) //8-way ceiling flipping (bits 2,4,5) { i = sector[searchsector].ceilingstat; i = (i&0x4)+((i>>4)&3); @@ -5441,7 +5366,7 @@ static void Keys3d(void) sector[searchsector].floorstat |= i; asksave = 1; } - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { i = sprite[searchwall].cstat; if (((i&48) == 32) && ((i&64) == 0)) @@ -5487,16 +5412,22 @@ static void Keys3d(void) else updownunits = 1024; mouseaction=0; - if (eitherALT && bstatus&1) + if (eitherALT && (bstatus&1)) { mousex=0; mskip=1; - if (mousey<0) + if (mousey!=0) { updownunits=klabs(mousey*128); mouseaction=1; } } - if (keystatus[KEYSC_PGUP] || mouseaction || ((bstatus&2) && (bstatus&16 && !(bstatus&1)))) // PK: PGUP, rmb only & mwheel + + tsign = 0; + if (keystatus[KEYSC_PGUP] || (mouseaction && mousey<0) || ((bstatus&2) && (bstatus&16) && !(bstatus&1))) // PK: PGUP, rmb only & mwheel + tsign = -1; + if (keystatus[KEYSC_PGDN] || (mouseaction && mousey>0) || ((bstatus&2) && (bstatus&32) && !(bstatus&1))) // PK: PGDN, rmb only & mwheel + tsign = 1; + if (tsign) { k = 0; if (highlightsectorcnt >= 0) @@ -5504,97 +5435,70 @@ static void Keys3d(void) for (i=0; i=0) ? wall[searchwall].nextsector : searchsector); + + for (j=0; j<(k?k:1); j++, sect=highlightsector[j]) { - i = headspritesect[searchsector]; + i = headspritesect[sect]; while (i != -1) { - tempint = getceilzofslope(searchsector,sprite[i].x,sprite[i].y); + tempint = getceilzofslope(sect,sprite[i].x,sprite[i].y); tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2); if (sprite[i].cstat&128) tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); if (sprite[i].z == tempint) - sprite[i].z -= updownunits << (eitherCTRL<<1); // JBF 20031128 + sprite[i].z += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 i = nextspritesect[i]; } - sector[searchsector].ceilingz -= updownunits << (eitherCTRL<<1); // JBF 20031128 - Bsprintf(getmessage,"Sector %d ceilingz = %d",searchsector,sector[searchsector].ceilingz); + sector[sect].ceilingz += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 + Bsprintf(getmessage,"Sector %d ceilingz = %d",sect,sector[sect].ceilingz); message(getmessage); - - } - else - { - for (j=0; j0) - { - updownunits=klabs(mousey*128); - mouseaction=1; - } - } - if (keystatus[KEYSC_PGDN] || mouseaction || ((bstatus&2) && (bstatus&32) && !(bstatus&1))) // PK: PGDN, rmb only & mwheel - { - k = 0; - if (highlightsectorcnt >= 0) - { - for (i=0; i sector[searchsector].floorz) - sector[searchsector].ceilingz = sector[searchsector].floorz; - if (searchstat == 3) - { - if (eitherCTRL && !eitherALT) //CTRL - put sprite on ground - { - sprite[searchwall].z = spriteongroundz(searchwall); - } - else - { - k = 0; - if (highlightcnt >= 0) - for (i=0; i0)) // ] + tsign = 1; + + if (tsign) { - keystatus[KEYSC_LBRACK] = 0; + keystatus[KEYSC_LBRACK] = keystatus[KEYSC_RBRACK] = 0; if (eitherALT) { i = wall[searchwall].nextsector; if (i >= 0 && !mouseaction) - switch (searchstat) + { + if (searchstat==SEARCH_CEILING || (tsign < 0 && (searchstat==SEARCH_WALL || searchstat==SEARCH_MASKWALL))) { - case 0: - case 1: - case 4: alignceilslope(searchsector,wall[searchwall].x,wall[searchwall].y,getceilzofslope(i,wall[searchwall].x,wall[searchwall].y)); message("Sector %d align ceiling to wall %d",searchsector,searchwall); - break; - case 2: + } + if (searchstat==SEARCH_FLOOR || (tsign > 0 && (searchstat==SEARCH_WALL || searchstat==SEARCH_MASKWALL))) + { alignflorslope(searchsector,wall[searchwall].x,wall[searchwall].y,getflorzofslope(i,wall[searchwall].x,wall[searchwall].y)); message("Sector %d align floor to wall %d",searchsector,searchwall); - break; } + } } else { - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { if (!(sector[searchsector].ceilingstat&2)) sector[searchsector].ceilingheinum = 0; - sector[searchsector].ceilingheinum = max(sector[searchsector].ceilingheinum-i,-32768); + sector[searchsector].ceilingheinum = min(max(-32768, sector[searchsector].ceilingheinum + tsign*i), 32767); message("Sector %d ceiling slope = %d",searchsector,sector[searchsector].ceilingheinum); } - if (searchstat == 2) + if (searchstat == SEARCH_FLOOR) { if (!(sector[searchsector].floorstat&2)) sector[searchsector].floorheinum = 0; - sector[searchsector].floorheinum = max(sector[searchsector].floorheinum-i,-32768); + sector[searchsector].floorheinum = min(max(-32768, sector[searchsector].floorheinum + tsign*i), 32767); message("Sector %d floor slope = %d",searchsector,sector[searchsector].floorheinum); } } @@ -6447,77 +6211,13 @@ static void Keys3d(void) asksave = 1; } - i = 512; - if (keystatus[KEYSC_RSHIFT]) i = 8; - if (keystatus[KEYSC_LSHIFT]) i = 1; - mouseaction=0; - if (eitherCTRL && !eitherSHIFT && bstatus&1 && (searchstat == 1 || searchstat == 2)) - { - mousex=0; mskip=1; - if (mousey>0) - { - i=klabs(mousey*2); - mouseaction=1; - } - } - if (keystatus[KEYSC_RBRACK] || mouseaction) // ] - { - keystatus[KEYSC_RBRACK] = 0; - if (eitherALT) - { - i = wall[searchwall].nextsector; - if (i >= 0 && !mouseaction) - switch (searchstat) - { - case 1: - alignceilslope(searchsector,wall[searchwall].x,wall[searchwall].y,getceilzofslope(i,wall[searchwall].x,wall[searchwall].y)); - message("Sector %d align ceiling to wall %d",searchsector,searchwall); - break; - case 0: - case 2: - case 4: - alignflorslope(searchsector,wall[searchwall].x,wall[searchwall].y,getflorzofslope(i,wall[searchwall].x,wall[searchwall].y)); - message("Sector %d align floor to wall %d",searchsector,searchwall); - break; - } - } - else - { - if (searchstat == 1) - { - if (!(sector[searchsector].ceilingstat&2)) - sector[searchsector].ceilingheinum = 0; - sector[searchsector].ceilingheinum = min(sector[searchsector].ceilingheinum+i,32767); - message("Sector %d ceiling slope = %d",searchsector,sector[searchsector].ceilingheinum); - } - if (searchstat == 2) - { - if (!(sector[searchsector].floorstat&2)) - sector[searchsector].floorheinum = 0; - sector[searchsector].floorheinum = min(sector[searchsector].floorheinum+i,32767); - message("Sector %d floor slope = %d",searchsector,sector[searchsector].floorheinum); - } - } - - if (sector[searchsector].ceilingheinum == 0) - sector[searchsector].ceilingstat &= ~2; - else - sector[searchsector].ceilingstat |= 2; - - if (sector[searchsector].floorheinum == 0) - sector[searchsector].floorstat &= ~2; - else - sector[searchsector].floorstat |= 2; - - asksave = 1; - } if (bstatus&1 && eitherSHIFT) mskip=1; - if (bstatus&1 && eitherSHIFT && (searchstat == 1 || searchstat == 2) && (mousex|mousey)) + if (bstatus&1 && eitherSHIFT && (searchstat == SEARCH_CEILING || searchstat == SEARCH_FLOOR) && (mousex|mousey)) { int32_t fw,x1,y1,x2,y2,stat,ma,a=0; - stat=(searchstat==2)?sector[searchsector].floorstat:sector[searchsector].ceilingstat; + stat=(searchstat==SEARCH_FLOOR)?sector[searchsector].floorstat:sector[searchsector].ceilingstat; if (stat&64) // align to first wall { fw=sector[searchsector].wallptr; @@ -6565,7 +6265,7 @@ static void Keys3d(void) if (x1||y1) { mouseax=0; mouseay=0; - if (searchstat==1) + if (searchstat==SEARCH_CEILING) { changedir=1; if (x1<0) {changedir=-1; x1*=-1;} while (x1--)sector[searchsector].ceilingxpanning = changechar(sector[searchsector].ceilingxpanning,changedir,0,0); @@ -6594,7 +6294,7 @@ static void Keys3d(void) updownunits=1; mouseaction=0; - if (bstatus&1 && searchstat != 1 && searchstat != 2) + if (bstatus&1 && searchstat != SEARCH_CEILING && searchstat != SEARCH_FLOOR) { if (eitherSHIFT) { @@ -6614,7 +6314,7 @@ static void Keys3d(void) { mouseaction=2; repeatpanalign=0; - if (searchstat==3) + if (searchstat==SEARCH_SPRITE) { updownunits=klabs(mouseax+=mousex)/4; if (updownunits)mouseax=0; @@ -6636,7 +6336,7 @@ static void Keys3d(void) if (keystatus[KEYSC_gLEFT] || mousex>0) changedir = -1; if (keystatus[KEYSC_gRIGHT] || mousex<0) changedir = 1; - if ((searchstat == 0) || (searchstat == 4)) + if ((searchstat == SEARCH_WALL) || (searchstat == SEARCH_MASKWALL)) { if (repeatpanalign == 0) { @@ -6645,7 +6345,7 @@ static void Keys3d(void) } else { - int16_t w = (searchstat==0)?searchbottomwall:searchwall; + int16_t w = (searchstat==SEARCH_WALL)?searchbottomwall:searchwall; if (mouseaction) { i=wall[w].cstat; @@ -6657,9 +6357,9 @@ static void Keys3d(void) message("Wall %d panning: %d, %d",w,wall[w].xpanning,wall[w].ypanning); } } - if ((searchstat == 1) || (searchstat == 2)) + if ((searchstat == SEARCH_CEILING) || (searchstat == SEARCH_FLOOR)) { - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { while (updownunits--)sector[searchsector].ceilingxpanning = changechar(sector[searchsector].ceilingxpanning,changedir,smooshyalign,0); message("Sector %d ceiling panning: %d, %d",searchsector,sector[searchsector].ceilingxpanning,sector[searchsector].ceilingypanning); @@ -6670,7 +6370,7 @@ static void Keys3d(void) message("Sector %d floor panning: %d, %d",searchsector,sector[searchsector].floorxpanning,sector[searchsector].floorypanning); } } - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { static int32_t sumxvect=0, sumyvect=0; @@ -6733,7 +6433,7 @@ static void Keys3d(void) updownunits=1; mouseaction=0; - if (bstatus&1 && searchstat != 1 && searchstat != 2) + if (bstatus&1 && searchstat != SEARCH_CEILING && searchstat != SEARCH_FLOOR) { if (eitherSHIFT) { @@ -6742,7 +6442,7 @@ static void Keys3d(void) { mouseaction=1; updownunits=klabs(mousey); - if (searchstat != 3) + if (searchstat != SEARCH_SPRITE) { updownunits=klabs((int32_t)(mousey*128./tilesizy[wall[searchwall].picnum])); } @@ -6755,7 +6455,7 @@ static void Keys3d(void) { mouseaction=2; repeatpanalign=0; - if (searchstat==3) + if (searchstat==SEARCH_SPRITE) { updownunits=klabs(mouseay+=mousey)/4; if (updownunits)mouseay=0; @@ -6777,7 +6477,7 @@ static void Keys3d(void) if (keystatus[KEYSC_gUP] || mousey>0) changedir = -1; if (keystatus[KEYSC_gDOWN] || mousey<0) changedir = 1; - if ((searchstat == 0) || (searchstat == 4)) + if ((searchstat == SEARCH_WALL) || (searchstat == SEARCH_MASKWALL)) { if (repeatpanalign == 0) { @@ -6787,7 +6487,7 @@ static void Keys3d(void) } else { - int16_t w = (searchstat==0)?searchbottomwall:searchwall; + int16_t w = (searchstat==SEARCH_WALL)?searchbottomwall:searchwall; if (mouseaction && eitherCTRL) updownunits *= 8; while (updownunits--) @@ -6795,9 +6495,9 @@ static void Keys3d(void) message("Wall %d panning: %d, %d",w,wall[w].xpanning,wall[w].ypanning); } } - if ((searchstat == 1) || (searchstat == 2)) + if ((searchstat == SEARCH_CEILING) || (searchstat == SEARCH_FLOOR)) { - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { while (updownunits--) sector[searchsector].ceilingypanning = changechar(sector[searchsector].ceilingypanning,changedir,smooshyalign,0); @@ -6810,7 +6510,7 @@ static void Keys3d(void) message("Sector %d floor panning: %d, %d",searchsector,sector[searchsector].floorxpanning,sector[searchsector].floorypanning); } } - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { static int32_t sumxvect=0, sumyvect=0; @@ -6894,7 +6594,7 @@ static void Keys3d(void) if (keystatus[KEYSC_TAB]) //TAB { - if (searchstat == 0) + if (searchstat == SEARCH_WALL) { temppicnum = wall[searchbottomwall].picnum; tempshade = wall[searchbottomwall].shade; @@ -6906,7 +6606,7 @@ static void Keys3d(void) temphitag = wall[searchbottomwall].hitag; tempextra = wall[searchbottomwall].extra; } - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { temppicnum = sector[searchsector].ceilingpicnum; tempshade = sector[searchsector].ceilingshade; @@ -6919,7 +6619,7 @@ static void Keys3d(void) temphitag = sector[searchsector].hitag; tempextra = sector[searchsector].extra; } - if (searchstat == 2) + if (searchstat == SEARCH_FLOOR) { temppicnum = sector[searchsector].floorpicnum; tempshade = sector[searchsector].floorshade; @@ -6932,7 +6632,7 @@ static void Keys3d(void) temphitag = sector[searchsector].hitag; tempextra = sector[searchsector].extra; } - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { temppicnum = sprite[searchwall].picnum; tempshade = sprite[searchwall].shade; @@ -6947,7 +6647,7 @@ static void Keys3d(void) tempyvel = sprite[searchwall].yvel; tempzvel = sprite[searchwall].zvel; } - if (searchstat == 4) + if (searchstat == SEARCH_MASKWALL) { temppicnum = wall[searchwall].overpicnum; tempshade = wall[searchwall].shade; @@ -6970,7 +6670,7 @@ static void Keys3d(void) int32_t dashade[2]; if (eitherSHIFT) { - if (((searchstat == 0) || (searchstat == 4)) && eitherCTRL) //Ctrl-shift Enter (auto-shade) + if (((searchstat == SEARCH_WALL) || (searchstat == SEARCH_MASKWALL)) && eitherCTRL) //Ctrl-shift Enter (auto-shade) { dashade[0] = 127; dashade[1] = -128; @@ -7001,29 +6701,29 @@ static void Keys3d(void) } else if (somethingintab < 255) { - if (searchstat == 0) + if (searchstat == SEARCH_WALL) { wall[searchbottomwall].shade = tempshade; wall[searchbottomwall].pal = temppal; } - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { sector[searchsector].ceilingshade = tempshade, sector[searchsector].ceilingpal = temppal; if ((somethingintab == 1) || (somethingintab == 2)) sector[searchsector].visibility = tempvis; } - if (searchstat == 2) + if (searchstat == SEARCH_FLOOR) { sector[searchsector].floorshade = tempshade, sector[searchsector].floorpal = temppal; if ((somethingintab == 1) || (somethingintab == 2)) sector[searchsector].visibility = tempvis; } - if (searchstat == 3) sprite[searchwall].shade = tempshade, sprite[searchwall].pal = temppal; - if (searchstat == 4) wall[searchwall].shade = tempshade, wall[searchwall].pal = temppal; + if (searchstat == SEARCH_SPRITE) sprite[searchwall].shade = tempshade, sprite[searchwall].pal = temppal; + if (searchstat == SEARCH_MASKWALL) wall[searchwall].shade = tempshade, wall[searchwall].pal = temppal; message("Pasted shading+pal"); } } - else if (((searchstat == 0) || (searchstat == 4)) && eitherCTRL && (somethingintab < 255)) //Either ctrl key + else if (((searchstat == SEARCH_WALL) || (searchstat == SEARCH_MASKWALL)) && eitherCTRL && (somethingintab < 255)) //Either ctrl key { i = searchwall; do @@ -7043,10 +6743,10 @@ static void Keys3d(void) while (i != searchwall); message("Pasted picnum+shading+pal"); } - else if (((searchstat == 1) || (searchstat == 2)) && eitherCTRL && (somethingintab < 255)) //Either ctrl key + else if (((searchstat == SEARCH_CEILING) || (searchstat == SEARCH_FLOOR)) && eitherCTRL && (somethingintab < 255)) //Either ctrl key { clearbuf(&pskysearch[0],(int32_t)((numsectors+3)>>2),0L); - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { i = searchsector; if ((sector[i].ceilingstat&1) > 0) @@ -7081,7 +6781,7 @@ static void Keys3d(void) i = j; } } - if (searchstat == 2) + if (searchstat == SEARCH_FLOOR) { i = searchsector; if ((sector[i].floorstat&1) > 0) @@ -7120,7 +6820,7 @@ static void Keys3d(void) } else if (somethingintab < 255) { - if (searchstat == 0) + if (searchstat == SEARCH_WALL) { wall[searchbottomwall].picnum = temppicnum; wall[searchbottomwall].shade = tempshade; @@ -7136,7 +6836,7 @@ static void Keys3d(void) } fixrepeats(searchwall); } - if (searchstat == 1) + if (searchstat == SEARCH_CEILING) { sector[searchsector].ceilingpicnum = temppicnum; sector[searchsector].ceilingshade = tempshade; @@ -7152,7 +6852,7 @@ static void Keys3d(void) sector[searchsector].extra = tempextra; } } - if (searchstat == 2) + if (searchstat == SEARCH_FLOOR) { sector[searchsector].floorpicnum = temppicnum; sector[searchsector].floorshade = tempshade; @@ -7168,7 +6868,7 @@ static void Keys3d(void) sector[searchsector].extra = tempextra; } } - if (searchstat == 3) + if (searchstat == SEARCH_SPRITE) { sprite[searchwall].picnum = temppicnum; if ((tilesizx[temppicnum] <= 0) || (tilesizy[temppicnum] <= 0)) @@ -7199,7 +6899,7 @@ static void Keys3d(void) sprite[searchwall].zvel = tempzvel; } } - if (searchstat == 4) + if (searchstat == SEARCH_MASKWALL) { wall[searchwall].overpicnum = temppicnum; if (wall[searchwall].nextwall >= 0) @@ -7232,28 +6932,28 @@ static void Keys3d(void) { switch (searchstat) { - case 0: + case SEARCH_WALL: j = wall[searchbottomwall].picnum; for (i=0; i=0; i--) if (sprite[i].picnum == SECTOREFFECTOR && (sprite[i].lotag == 12 || sprite[i].lotag == 3)) { - int32_t w; - int32_t start_wall = sector[sprite[i].sectnum].wallptr; - int32_t end_wall = start_wall + sector[sprite[i].sectnum].wallnum; + int32_t w, isec=sprite[i].sectnum; + int32_t start_wall = sector[isec].wallptr; + int32_t end_wall = start_wall + sector[isec].wallnum; for (w = start_wall; w < end_wall; w++) { @@ -10066,15 +9766,15 @@ void ExtPreCheckKeys(void) // just before drawrooms } } */ } - sectorshades[sprite[i].sectnum][0] = sector[sprite[i].sectnum].floorshade; - sectorshades[sprite[i].sectnum][1] = sector[sprite[i].sectnum].ceilingshade; - sector[sprite[i].sectnum].floorshade = sprite[i].shade; - sector[sprite[i].sectnum].ceilingshade = sprite[i].shade; - sectorpals[sprite[i].sectnum][0] = sector[sprite[i].sectnum].floorpal; - sectorpals[sprite[i].sectnum][1] = sector[sprite[i].sectnum].ceilingpal; - sector[sprite[i].sectnum].floorpal = sprite[i].pal; - sector[sprite[i].sectnum].ceilingpal = sprite[i].pal; - w = headspritesect[sprite[i].sectnum]; + sectorshades[isec][0] = sector[isec].floorshade; + sectorshades[isec][1] = sector[isec].ceilingshade; + sector[isec].floorshade = sprite[i].shade; + sector[isec].ceilingshade = sprite[i].shade; + sectorpals[isec][0] = sector[isec].floorpal; + sectorpals[isec][1] = sector[isec].ceilingpal; + sector[isec].floorpal = sprite[i].pal; + sector[isec].ceilingpal = sprite[i].pal; + w = headspritesect[isec]; while (w >= 0) { if (w == i) { w = nextspritesect[w]; continue; } @@ -10828,9 +10528,9 @@ void ExtCheckKeys(void) for (i=numsprites-1; i>=0; i--) if (sprite[i].picnum == SECTOREFFECTOR && (sprite[i].lotag == 12 || sprite[i].lotag == 3)) { - int32_t w; - int32_t start_wall = sector[sprite[i].sectnum].wallptr; - int32_t end_wall = start_wall + sector[sprite[i].sectnum].wallnum; + int32_t w, isec=sprite[i].sectnum; + int32_t start_wall = sector[isec].wallptr; + int32_t end_wall = start_wall + sector[isec].wallnum; for (w = start_wall; w < end_wall; w++) { @@ -10850,12 +10550,12 @@ void ExtCheckKeys(void) } } */ } - sector[sprite[i].sectnum].floorshade = sectorshades[sprite[i].sectnum][0]; - sector[sprite[i].sectnum].ceilingshade = sectorshades[sprite[i].sectnum][1]; - sector[sprite[i].sectnum].floorpal = sectorpals[sprite[i].sectnum][0]; - sector[sprite[i].sectnum].ceilingpal = sectorpals[sprite[i].sectnum][1]; + sector[isec].floorshade = sectorshades[isec][0]; + sector[isec].ceilingshade = sectorshades[isec][1]; + sector[isec].floorpal = sectorpals[isec][0]; + sector[isec].ceilingpal = sectorpals[isec][1]; - w = headspritesect[sprite[i].sectnum]; + w = headspritesect[isec]; while (w >= 0) { if (w == i) { w = nextspritesect[w]; continue; } diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 6f59058f1..a9a3104a2 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -9200,8 +9200,7 @@ GAME_STATIC void G_HandleLocalKeys(void) if (KB_KeyPressed(sc_Return) && ud.multimode==1) { KB_ClearKeyDown(sc_Return); - ud.reccnt = 0; - ud.recstat = 0; + g_demo_cnt = g_demo_goalCnt = ud.reccnt = ud.pause_on = ud.recstat = ud.m_recstat = 0; kclose(g_demo_recFilePtr); g_player[myconnectindex].ps->gm = MODE_GAME; // ready2send=0; @@ -12019,7 +12018,7 @@ GAME_STATIC int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine ud.reccnt = 0; ud.god = ud.cashman = ud.eog = ud.showallmap = 0; - ud.clipping = ud.scrollmode = ud.overhead_on = ud.pause_on = 0; + ud.clipping = ud.scrollmode = ud.overhead_on = 0; //= ud.pause_on = 0; // G_NewGame(ud.volume_number,ud.level_number,ud.player_skill); // G_ResetTimers(); @@ -12043,7 +12042,7 @@ corrupt: } #if KRANDDEBUG -extern int32_t krd_enable(); +extern void krd_enable(int32_t which); extern int32_t krd_print(const char *filename); #endif @@ -12059,16 +12058,15 @@ void G_OpenDemoWrite(void) { Bstrcpy(ScriptQuotes[122], "CANNOT START DEMO RECORDING WHEN DEAD!"); P_DoQuote(122, g_player[myconnectindex].ps); - ud.recstat = 0; + ud.recstat = ud.m_recstat = 0; return; } if (demorec_diffs_cvar && !demorec_force_cvar) - for (i=1; i>12) && i=0 && script[i+1]>12) && script[i+1]>=0 && script[i+1]0 && g_demo_goalCnt < g_demo_cnt) // rewind { k = g_player[myconnectindex].ps->gm&MODE_MENU; @@ -12354,8 +12348,8 @@ RECHECK: g_demo_cnt = 1; ud.reccnt = 0; - ud.god = ud.cashman = ud.eog = ud.showallmap = 0; - ud.clipping = ud.scrollmode = ud.overhead_on = ud.pause_on = 0; +// ud.god = ud.cashman = ud.eog = ud.showallmap = 0; +// ud.clipping = ud.scrollmode = ud.overhead_on = ud.pause_on = 0; totalclock = ototalclock = lockclock = 0; } @@ -12414,9 +12408,6 @@ RECHECK: goto nextdemo; else CORRUPT(12); - if (demo_hasseeds) - outofsync = (uint16_t)(randomseed>>24) != g_demo_seedbuf[bigi]; - if (0) { corrupt: @@ -12435,6 +12426,9 @@ nextdemo: } } + if (demo_hasseeds) + outofsync = (uint8_t)(randomseed>>24) != g_demo_seedbuf[bigi]; + TRAVERSE_CONNECT(j) { copybufbyte(&recsync[bigi], &inputfifo[0][j], sizeof(input_t)); @@ -12595,7 +12589,12 @@ nextdemo: if (g_player[myconnectindex].ps->gm==MODE_END || g_player[myconnectindex].ps->gm==MODE_GAME) { if (foundemo) + { +#if KRANDDEBUG + krd_print("krandplay.log"); +#endif kclose(g_demo_recFilePtr); + } return 0; } } @@ -12618,7 +12617,8 @@ nextdemo: if (g_player[myconnectindex].ps->gm&MODE_MENU) goto RECHECK; #if KRANDDEBUG - krd_print("krandplay.log"); + if (foundemo) + krd_print("krandplay.log"); #endif return 1; } @@ -12702,7 +12702,7 @@ GAME_STATIC int32_t G_DoMoveThings(void) ud.camerasprite = -1; lockclock += TICSPERFRAME; - if (g_earthquakeTime > 0) g_earthquakeTime--; + //if (g_earthquakeTime > 0) g_earthquakeTime--; moved lower so it is restored correctly by diffs if (g_RTSPlaying > 0) g_RTSPlaying--; for (i=0; i 0) g_earthquakeTime--; + #ifdef POLYMER if (ud.pause_on == 0) gamelightcount = 0; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 0ecf861c4..6700a6d83 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -2807,7 +2807,7 @@ cheat_for_port_credits: } if ((g_player[myconnectindex].ps->gm&MODE_GAME) && ud.m_recstat != 1) enabled = 0; - mgametextpal(d,yy,ud.m_recstat?((ud.m_recstat && enabled && g_player[myconnectindex].ps->gm&MODE_GAME)?"Running":"On"):"Off",enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE,enabled?0:1); + mgametextpal(d,yy,ud.m_recstat?((enabled && g_player[myconnectindex].ps->gm&MODE_GAME)?"Running":"On"):"Off",enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE,enabled?0:1); break; case 12: if (x==io) ChangeToMenu(201); diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index c389e617c..84a5fed7a 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -935,7 +935,7 @@ typedef struct dataspec_ } dataspec_t; #define SV_MAJOR_VER 0 -#define SV_MINOR_VER 1 +#define SV_MINOR_VER 2 #define SV_DEFAULTCOMPRTHRES 8 static uint8_t savegame_diffcompress; // 0:none, 1:Ken's LZW in cache1d.c static uint8_t savegame_comprthres; @@ -966,7 +966,7 @@ static int32_t ds_getcnt(const dataspec_t *sp) } } -static void ds_get(const dataspec_t *sp, void **ptr, int32_t *cnt) +static void ds_get(const dataspec_t *sp, const void **ptr, int32_t *cnt) { *cnt = ds_getcnt(sp); @@ -1067,7 +1067,7 @@ static int32_t readspecdata(const dataspec_t *spec, int32_t fil, uint8_t **dumpv continue; } - ds_get(sp, &ptr, &cnt); + ds_get(sp, (const void **)&ptr, &cnt); if (cnt < 0) { OSD_Printf("rsd: cnt<0... wtf?\n"); return -1; } if (fil>=0) @@ -1360,6 +1360,7 @@ static void sv_prespriteextsave(); static void sv_postspriteext(); static void sv_calcbitptrsize(); static void sv_prescriptsave_once(); +static void sv_prescriptload_once(); static void sv_postscript_once(); static void sv_preactordatasave(); static void sv_postactordata(); @@ -1413,6 +1414,7 @@ static const dataspec_t svgm_udnetw[] = { DS_NOCHK, &ud.ffire, sizeof(ud.ffire), 1 }, { DS_NOCHK, &ud.noexits, sizeof(ud.noexits), 1 }, { DS_NOCHK, &ud.playerai, sizeof(ud.playerai), 1 }, + { 0, &ud.pause_on, sizeof(ud.pause_on), 1 }, { DS_NOCHK, ¤tboardfilename[0], BMAX_PATH, 1 }, { DS_LOADFN, (void *)&sv_postudload, 0, 1 }, { 0, &connecthead, sizeof(connecthead), 1 }, @@ -1472,6 +1474,7 @@ static const dataspec_t svgm_script[] = { DS_SAVEFN|DS_NOCHK, (void *)&sv_prescriptsave_once, 0, 1 }, { DS_NOCHK, &actorscrptr[0], sizeof(actorscrptr[0]), MAXTILES }, + { DS_LOADFN|DS_NOCHK, (void *)&sv_prescriptload_once, 0, 1 }, { DS_DYNAMIC|DS_CNT(g_scriptSize)|DS_NOCHK, &script, sizeof(script[0]), (intptr_t)&g_scriptSize }, { DS_NOCHK, &actorLoadEventScrptr[0], sizeof(actorLoadEventScrptr[0]), MAXTILES }, // { DS_NOCHK, &apScriptGameEvent[0], sizeof(apScriptGameEvent[0]), MAXGAMEEVENTS }, @@ -1498,6 +1501,9 @@ static const dataspec_t svgm_anmisc[] = { 0, &camsprite, sizeof(camsprite), 1 }, { 0, &msx[0], sizeof(msx[0]), sizeof(msx)/sizeof(msx[0]) }, { 0, &msy[0], sizeof(msy[0]), sizeof(msy)/sizeof(msy[0]) }, + { 0, &g_spriteDeleteQueuePos, sizeof(g_spriteDeleteQueuePos), 1 }, + { DS_NOCHK, &g_spriteDeleteQueueSize, sizeof(g_spriteDeleteQueueSize), 1 }, + { DS_CNT(g_spriteDeleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_spriteDeleteQueueSize }, { 0, &show2dsector[0], sizeof(uint8_t), MAXSECTORS>>3 }, { DS_NOCHK, &g_numClouds, sizeof(g_numClouds), 1 }, { 0, &clouds[0], sizeof(clouds), 1 }, @@ -1543,7 +1549,7 @@ static uint8_t *svdiff; #include "gamedef.h" -#define SV_SKIPMASK (GAMEVAR_SYSTEM|GAMEVAR_READONLY|GAMEVAR_INTPTR| \ +#define SV_SKIPMASK (/*GAMEVAR_SYSTEM|*/GAMEVAR_READONLY|GAMEVAR_INTPTR| \ GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR /*|GAMEVAR_NORESET*/ |GAMEVAR_SPECIAL) // setup gamevar data spec for snapshotting and diffing... gamevars must be loaded when called static void sv_makevarspec() @@ -1811,6 +1817,7 @@ int32_t sv_readdiff(int32_t fil) static void sv_postudload() { Bmemcpy(&boardfilename[0], ¤tboardfilename[0], BMAX_PATH); +#if 0 ud.m_level_number = ud.level_number; ud.m_volume_number = ud.volume_number; ud.m_player_skill = ud.player_skill; @@ -1822,11 +1829,10 @@ static void sv_postudload() ud.m_marker = ud.marker; ud.m_ffire = ud.ffire; ud.m_noexits = ud.noexits; +#endif } //static int32_t lockclock_dummy; - - #if defined(POLYMOST) && defined(USE_OPENGL) static void sv_prespriteextsave() { @@ -1865,6 +1871,12 @@ static void sv_prescriptsave_once() if (actorLoadEventScrptr[i]) actorLoadEventScrptr[i] = (intptr_t *)(actorLoadEventScrptr[i]-&script[0]); } +static void sv_prescriptload_once() +{ + if (script) + Bfree(script); + script = Bmalloc(g_scriptSize * sizeof(script[0])); +} static void sv_postscript_once() { int32_t i; @@ -2107,7 +2119,7 @@ static int32_t doloadplayer2(int32_t spot, int32_t fil, uint8_t **memptr) if (spot >= 0 && ud.multimode!=numplayers) return 2; - if (numplayers > 1) + if (spot<0 || numplayers > 1) { if (LOADRDU(&tbuf, 19, 1)) return -3; } diff --git a/polymer/eduke32/source/sdlmusic.c b/polymer/eduke32/source/sdlmusic.c index c152b5604..68ebec119 100644 --- a/polymer/eduke32/source/sdlmusic.c +++ b/polymer/eduke32/source/sdlmusic.c @@ -116,15 +116,19 @@ int32_t MUSIC_Init(int32_t SoundCard, int32_t Address) external_midi = (command != NULL && command[0] != 0); - if (external_midi) - Mix_SetMusicCMD(command); - else - { - char *s[] = { "/etc/timidity.cfg", "/etc/timidity/timidity.cfg", "/etc/timidity/freepats.cfg" }; - FILE *fp = NULL; - int32_t i; - - for (i = (sizeof(s)/sizeof(s[0]))-1; i>=0; i--) + if (external_midi) + { + initprintf("Setting music command to `%s'.\n", command); + if (Mix_SetMusicCMD(command)==-1) + perror("Mix_SetMusicCMD"); + } + else + { + char *s[] = { "/etc/timidity.cfg", "/etc/timidity/timidity.cfg", "/etc/timidity/freepats.cfg" }; + FILE *fp = NULL; + int32_t i; + + for (i = (sizeof(s)/sizeof(s[0]))-1; i>=0; i--) { fp = Bfopen(s[i], "r"); if (fp == NULL) @@ -253,11 +257,30 @@ int32_t MUSIC_StopSong(void) // void MUSIC_PlayMusic(char *_filename) int32_t MUSIC_PlaySong(char *song, int32_t loopflag) { + static char *tempfn = "/tmp/eduke32-music.mid"; + FILE *fp; + MUSIC_StopSong(); - music_musicchunk = Mix_LoadMUS_RW(SDL_RWFromMem((char *) song, g_musicSize)); + + if (external_midi) + { + fp = Bfopen(tempfn, "wb"); + if (fp) + { + fwrite(song, 1, g_musicSize, fp); + Bfclose(fp); + music_musicchunk = Mix_LoadMUS(tempfn); + if (!music_musicchunk) + initprintf("Mix_LoadMUS: %s\n", Mix_GetError()); + } + else initprintf("MUSIC_PlaySong: fopen: %s\n", strerror(errno)); + } + else + music_musicchunk = Mix_LoadMUS_RW(SDL_RWFromMem((char *) song, g_musicSize)); if (music_musicchunk != NULL) - Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_LoopSong)?-1:0); + if (Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_LoopSong)?-1:0) == -1) + initprintf("Mix_PlayMusic: %s\n", Mix_GetError()); return MUSIC_Ok; } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index bfba78474..7d77c15fe 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -329,7 +329,7 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel) if (fp < 0) { - OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open '%s' for playback!",fn); + OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open '%s' for playback!\n",fn); return 0; }