diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index a3b8bf2e4..aea23932f 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -478,7 +478,7 @@ extern long *actorLoadEventScrptr[MAXTILES]; extern char actortype[MAXTILES]; extern char *music_pointer; -extern char *music_fn[MAXVOLUMES+1][MAXLEVELS],music_select; +extern char music_select; extern char env_music_fn[MAXVOLUMES+1][BMAX_PATH]; extern short camsprite; @@ -539,8 +539,6 @@ extern int screencapt; extern short soundps[NUM_SOUNDS],soundpe[NUM_SOUNDS],soundvo[NUM_SOUNDS]; extern char soundpr[NUM_SOUNDS],soundm[NUM_SOUNDS]; extern long soundsiz[NUM_SOUNDS]; -extern char *level_names[MAXVOLUMES*MAXLEVELS]; -extern long partime[MAXVOLUMES*MAXLEVELS],designertime[MAXVOLUMES*MAXLEVELS]; extern char volume_names[MAXVOLUMES][33]; extern char skill_names[5][33]; @@ -574,7 +572,6 @@ enum gametypeflags { #define GTFLAGS(x) (gametype_flags[ud.coop] & x) -extern char *level_file_names[MAXVOLUMES*MAXLEVELS]; extern char num_volumes; extern int lastsavedpos; @@ -898,6 +895,13 @@ extern int redefined_quote_count; extern char setupfilename[BMAX_PATH]; +typedef struct { + char *name, *filename, *musicfn; + long partime, designertime; +} map_t; + +extern map_t map[MAXVOLUMES*MAXLEVELS]; + #ifdef __cplusplus } #endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 8890c1964..e5e6bd5f2 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -925,7 +925,7 @@ void getpackets(void) voting = packbuf[2]; vote_episode = packbuf[3]; vote_map = packbuf[4]; - Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)",ud.user_name[(unsigned char)packbuf[2]],level_names[(unsigned char)(packbuf[3]*MAXLEVELS + packbuf[4])],packbuf[3]+1,packbuf[4]+1); + Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)",ud.user_name[(unsigned char)packbuf[2]],map[(unsigned char)(packbuf[3]*MAXLEVELS + packbuf[4])].name,packbuf[3]+1,packbuf[4]+1); adduserquote(tempbuf); Bsprintf(tempbuf,"PRESS F1 TO VOTE YES, F2 TO VOTE NO"); adduserquote(tempbuf); @@ -3380,7 +3380,7 @@ void displayrest(long smoothratio) else a = 182; minitext(1,a+6,volume_names[ud.volume_number],0,2+8+16); - minitext(1,a+12,level_names[ud.volume_number*MAXLEVELS + ud.level_number],0,2+8+16); + minitext(1,a+12,map[ud.volume_number*MAXLEVELS + ud.level_number].name,0,2+8+16); } } } @@ -7462,7 +7462,7 @@ FOUNDCHEAT: levnume--; if ((VOLUMEONE && volnume > 0) || volnume > num_volumes-1 || - levnume >= MAXLEVELS || level_file_names[volnume*MAXLEVELS+levnume] == NULL) + levnume >= MAXLEVELS || map[volnume*MAXLEVELS+levnume].filename == NULL) { ps[myconnectindex].cheat_phase = 0; KB_FlushKeyBoardQueue(); @@ -7845,15 +7845,15 @@ static void nonsharedkeys(void) { i = (VOLUMEALL?MAXVOLUMES*MAXLEVELS:6); music_select++; - while ((music_fn[0][(unsigned char)music_select] == NULL) && music_select < i) + while ((map[(unsigned char)music_select].musicfn == NULL) && music_select < i) music_select++; if (music_select == i) music_select = 0; - if (music_fn[0][(unsigned char)music_select] != NULL) + if (map[(unsigned char)music_select].musicfn != NULL) { - Bsprintf(fta_quotes[26],"PLAYING %s",&music_fn[0][(unsigned char)music_select][0]); + Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn[0]); FTA(26,&ps[myconnectindex]); - playmusic(&music_fn[0][(unsigned char)music_select][0]); + playmusic(&map[(unsigned char)music_select].musicfn[0]); } return; } @@ -8071,8 +8071,8 @@ FAKE_F3: if (KB_KeyPressed(sc_F5) && config.MusicDevice >= 0) { KB_ClearKeyDown(sc_F5); - if (music_fn[0][(unsigned char)music_select] != NULL) - Bstrcpy(fta_quotes[26],&music_fn[0][(unsigned char)music_select][0]); + if (map[(unsigned char)music_select].musicfn != NULL) + Bstrcpy(fta_quotes[26],&map[(unsigned char)music_select].musicfn[0]); else fta_quotes[26][0] = '\0'; Bstrcat(fta_quotes[26],". USE SHIFT-F5 TO CHANGE."); FTA(26,&ps[myconnectindex]); @@ -9270,12 +9270,12 @@ static void freeconmem(void) for (i=(MAXLEVELS*MAXVOLUMES)-1;i>=0;i--) { - if (level_names[i] != NULL) - Bfree(level_names[i]); - if (level_file_names[i] != NULL) - Bfree(level_file_names[i]); - if (music_fn[0][i] != NULL) - Bfree(music_fn[0][i]); + if (map[i].name != NULL) + Bfree(map[i].name); + if (map[i].filename != NULL) + Bfree(map[i].filename); + if (map[i].musicfn != NULL) + Bfree(map[i].musicfn); } for (i=MAXQUOTES-1;i>=0;i--) @@ -10412,7 +10412,7 @@ MAIN_LOOP_RESTART: { Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE FOR MAP",ud.user_name[voting]); gametext(160,40,tempbuf,0,2+8+16); - Bsprintf(tempbuf,"%s (E%dL%d)",level_names[vote_episode*MAXLEVELS + vote_map],vote_episode+1,vote_map+1); + Bsprintf(tempbuf,"%s (E%dL%d)",map[vote_episode*MAXLEVELS + vote_map].name,vote_episode+1,vote_map+1); gametext(160,48,tempbuf,0,2+8+16); gametext(160,70,"PRESS F1 TO VOTE YES, F2 TO VOTE NO",0,2+8+16); } @@ -11627,7 +11627,7 @@ void dobonus(int bonusonly) if (!lastmapname) lastmapname = Bstrrchr(boardfilename,'/'); if (!lastmapname) lastmapname = boardfilename; } - else lastmapname = level_names[(ud.volume_number*MAXLEVELS)+ud.last_level-1]; + else lastmapname = map[(ud.volume_number*MAXLEVELS)+ud.last_level-1].name; bonuscnt = 0; @@ -11938,7 +11938,7 @@ FRAGBONUS: if (PLUTOPAK) // JBF 20030804 rotatesprite((260)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,0,0,2+8,0,0,xdim-1,ydim-1); gametext(160,58+2,"MULTIPLAYER TOTALS",0,2+8+16); - gametext(160,58+10,level_names[(ud.volume_number*MAXLEVELS)+ud.last_level-1],0,2+8+16); + gametext(160,58+10,map[(ud.volume_number*MAXLEVELS)+ud.last_level-1].name,0,2+8+16); gametext(160,165,"PRESS ANY KEY TO CONTINUE",0,2+8+16); @@ -12045,11 +12045,11 @@ FRAGBONUS: totalclock = 0; tinc = 0; - playerbest = CONFIG_GetMapBestTime(level_file_names[ud.volume_number*MAXLEVELS+ud.last_level-1]); + playerbest = CONFIG_GetMapBestTime(map[ud.volume_number*MAXLEVELS+ud.last_level-1].filename); if (ps[myconnectindex].player_par < playerbest || playerbest < 0) { - CONFIG_SetMapBestTime(level_file_names[ud.volume_number*MAXLEVELS+ud.last_level-1], ps[myconnectindex].player_par); + CONFIG_SetMapBestTime(map[ud.volume_number*MAXLEVELS+ud.last_level-1].filename, ps[myconnectindex].player_par); // if(playerbest != -1) // playerbest = ps[myconnectindex].player_par; } @@ -12061,11 +12061,11 @@ FRAGBONUS: clockpad = max(clockpad,ij); if (!(ud.volume_number == 0 && ud.last_level-1 == 7)) { - for (ii=partime[ud.volume_number*MAXLEVELS+ud.last_level-1]/(26*60), ij=1; ii>9; ii/=10, ij++) ; + for (ii=map[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/(26*60), ij=1; ii>9; ii/=10, ij++) ; clockpad = max(clockpad,ij); if (!NAM) { - for (ii=designertime[ud.volume_number*MAXLEVELS+ud.last_level-1]/(26*60), ij=1; ii>9; ii/=10, ij++) ; + for (ii=map[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/(26*60), ij=1; ii>9; ii/=10, ij++) ; clockpad = max(clockpad,ij); } } @@ -12185,16 +12185,16 @@ FRAGBONUS: if (!(ud.volume_number == 0 && ud.last_level-1 == 7)) { Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, - (partime[ud.volume_number*MAXLEVELS+ud.last_level-1]/(26*60)), - (partime[ud.volume_number*MAXLEVELS+ud.last_level-1]/26)%60); + (map[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/(26*60)), + (map[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/26)%60); gametext((320>>2)+71,yy+9,tempbuf,0,2+8+16); yy+=10; if (!NAM) { Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, - (designertime[ud.volume_number*MAXLEVELS+ud.last_level-1]/(26*60)), - (designertime[ud.volume_number*MAXLEVELS+ud.last_level-1]/26)%60); + (map[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/(26*60)), + (map[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/26)%60); gametext((320>>2)+71,yy+9,tempbuf,0,2+8+16); yy+=10; } diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 192199883..804228edd 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1881,12 +1881,12 @@ static int parsecommand(void) } tempbuf[j+1] = '\0'; - if (music_fn[k][i] == NULL) - music_fn[k][i] = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); - else if ((Bstrlen(tempbuf)+1) > sizeof(music_fn[k][i])) - music_fn[k][i] = Brealloc(music_fn[k][i],(Bstrlen(tempbuf)+1)); + if (map[(k*MAXLEVELS)+i].musicfn == NULL) + map[(k*MAXLEVELS)+i].musicfn = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); + else if ((Bstrlen(tempbuf)+1) > sizeof(map[(k*MAXLEVELS)+i].musicfn)) + map[(k*MAXLEVELS)+i].musicfn = Brealloc(map[(k*MAXLEVELS)+i].musicfn,(Bstrlen(tempbuf)+1)); - Bstrcpy(music_fn[k][i],tempbuf); + Bstrcpy(map[(k*MAXLEVELS)+i].musicfn,tempbuf); textptr += j; if (i > MAXLEVELS-1) break; @@ -4065,25 +4065,25 @@ repeatcase: Bcorrectfilename(tempbuf,0); - if (level_file_names[j*MAXLEVELS+k] == NULL) - level_file_names[j*MAXLEVELS+k] = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); - else if ((Bstrlen(tempbuf)+1) > sizeof(level_file_names[j*MAXLEVELS+k])) - level_file_names[j*MAXLEVELS+k] = Brealloc(level_file_names[j*MAXLEVELS+k],(Bstrlen(tempbuf)+1)); + if (map[j*MAXLEVELS+k].filename == NULL) + map[j*MAXLEVELS+k].filename = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); + else if ((Bstrlen(tempbuf)+1) > sizeof(map[j*MAXLEVELS+k].filename)) + map[j*MAXLEVELS+k].filename = Brealloc(map[j*MAXLEVELS+k].filename,(Bstrlen(tempbuf)+1)); /* initprintf("level file name string len: %ld\n",Bstrlen(tempbuf)); */ - Bstrcpy(level_file_names[j*MAXLEVELS+k],tempbuf); + Bstrcpy(map[j*MAXLEVELS+k].filename,tempbuf); while (*textptr == ' ' || *textptr == '\t') textptr++; - partime[j*MAXLEVELS+k] = + map[j*MAXLEVELS+k].partime = (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); textptr += 5; while (*textptr == ' ' || *textptr == '\t') textptr++; - designertime[j*MAXLEVELS+k] = + map[j*MAXLEVELS+k].designertime = (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); @@ -4107,14 +4107,14 @@ repeatcase: tempbuf[i] = '\0'; - if (level_names[j*MAXLEVELS+k] == NULL) - level_names[j*MAXLEVELS+k] = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); - else if ((Bstrlen(tempbuf)+1) > sizeof(level_names[j*MAXLEVELS+k])) - level_names[j*MAXLEVELS+k] = Brealloc(level_names[j*MAXLEVELS+k],(Bstrlen(tempbuf)+1)); + if (map[j*MAXLEVELS+k].name == NULL) + map[j*MAXLEVELS+k].name = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); + else if ((Bstrlen(tempbuf)+1) > sizeof(map[j*MAXLEVELS+k].name)) + map[j*MAXLEVELS+k].name = Brealloc(map[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1)); /* initprintf("level name string len: %ld\n",Bstrlen(tempbuf)); */ - Bstrcpy(level_names[j*MAXLEVELS+k],tempbuf); + Bstrcpy(map[j*MAXLEVELS+k].name,tempbuf); return 0; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 68e1b8638..828b01f4a 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -6136,8 +6136,8 @@ static int parse(void) case CON_STARTTRACK: insptr++; music_select=*insptr++; - if (music_fn[ud.volume_number][(unsigned char)music_select] != NULL) - playmusic(&music_fn[ud.volume_number][(unsigned char)music_select][0]); + if (map[(unsigned char)music_select].musicfn != NULL) + playmusic(&map[(unsigned char)music_select].musicfn[0]); break; case CON_GETTEXTURECEILING: diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 8182a32f0..80cbb4f34 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -56,8 +56,8 @@ short mirrorwall[64], mirrorsector[64], mirrorcnt; int current_menu; -char *level_names[MAXVOLUMES*MAXLEVELS],*level_file_names[MAXVOLUMES*MAXLEVELS]; -long partime[MAXVOLUMES*MAXLEVELS],designertime[MAXVOLUMES*MAXLEVELS]; +map_t map[MAXVOLUMES*MAXLEVELS]; + char volume_names[MAXVOLUMES][33] = { "L.A. MELTDOWN", "LUNAR APOCALYPSE", "SHRAPNEL CITY" }; char skill_names[5][33] = { "PIECE OF CAKE", "LET'S ROCK", "COME GET SOME", "DAMN I'M GOOD" }; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index b8cc3e4b4..f231df4de 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -4232,8 +4232,8 @@ cheat_for_port_credits: { if (ud.recstat != 2 && ps[myconnectindex].gm&MODE_GAME) { - if (music_fn[0][(unsigned char)music_select] != NULL) - playmusic(&music_fn[0][(unsigned char)music_select][0]); + if (map[(unsigned char)music_select].musicfn != NULL) + playmusic(&map[(unsigned char)music_select].musicfn[0]); } else playmusic(&env_music_fn[0][0]); @@ -4836,7 +4836,7 @@ VOLUME_ALL_40x: if (ud.m_volume_number == 0 && ud.m_level_number > 6+(boardfilename[0]!=0)) ud.m_level_number = 0; - while (level_names[(ud.m_volume_number*MAXLEVELS)+ud.m_level_number] == NULL) + while (map[(ud.m_volume_number*MAXLEVELS)+ud.m_level_number].name == NULL) { if (ud.m_level_number < i || i == 0) ud.m_level_number--; @@ -4965,7 +4965,7 @@ VOLUME_ALL_40x: gametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); } - gametext(c+70,57+16+16-7-9,&level_names[MAXLEVELS*ud.m_volume_number+ud.m_level_number][0],MENUHIGHLIGHT(2),2+8+16); + gametext(c+70,57+16+16-7-9,&map[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name[0],MENUHIGHLIGHT(2),2+8+16); gametext(c+70,57+16+16+16-7-9,ud.m_monsters_off == 0 || ud.m_player_skill > 0?skill_names[ud.m_player_skill]:"NONE",MENUHIGHLIGHT(3),2+8+16); diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index cab9871ca..53602e458 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -363,8 +363,8 @@ static int osdcmd_restartsound(const osdfuncparm_t *parm) { if (ud.recstat != 2 && ps[myconnectindex].gm&MODE_GAME) { - if (music_fn[0][(unsigned char)music_select] != NULL) - playmusic(&music_fn[0][(unsigned char)music_select][0]); + if (map[(unsigned char)music_select].musicfn != NULL) + playmusic(&map[(unsigned char)music_select].musicfn[0]); } else playmusic(&env_music_fn[0][0]); } diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index da8aa5308..d56d2c2ef 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -351,8 +351,8 @@ static void dofrontscreens(char *statustext) else { menutext(160,90,0,0,"ENTERING"); - if (level_names[(ud.volume_number*MAXLEVELS) + ud.level_number] != NULL) - menutext(160,90+16+8,0,0,level_names[(ud.volume_number*MAXLEVELS) + ud.level_number]); + if (map[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) + menutext(160,90+16+8,0,0,map[(ud.volume_number*MAXLEVELS) + ud.level_number].name); } if (statustext) gametext(160,180,statustext,0,2+8+16); @@ -1556,8 +1556,8 @@ static void getlevelfromfilename(const char *fn, char *volume, char *level) { for (*level=0;*level