12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757 |
- #include "Precompiled.h"
- #include "globaldata.h"
- #include "Main.h"
- #include "sys/sys_session.h"
- #include "sys/sys_signin.h"
- #include "DoomLeaderboards.h"
- #include "d3xp/Game_Local.h"
- #include <stdio.h>
- #include "z_zone.h"
- #include "m_random.h"
- #include "m_swap.h"
- #include "i_system.h"
- #include "w_wad.h"
- #include "g_game.h"
- #include "r_local.h"
- #include "s_sound.h"
- #include "doomstat.h"
- #include "sounds.h"
- #include "v_video.h"
- #include "wi_stuff.h"
- const point_t lnodes[NUMEPISODES][NUMMAPS] =
- {
-
- {
- { 185, 164 },
- { 148, 143 },
- { 69, 122 },
- { 209, 102 },
- { 116, 89 },
- { 166, 55 },
- { 71, 56 },
- { 135, 29 },
- { 71, 24 }
- },
-
- {
- { 254, 25 },
- { 97, 50 },
- { 188, 64 },
- { 128, 78 },
- { 214, 92 },
- { 133, 130 },
- { 208, 136 },
- { 148, 140 },
- { 235, 158 }
- },
-
- {
- { 156, 168 },
- { 48, 154 },
- { 174, 95 },
- { 265, 75 },
- { 130, 48 },
- { 279, 23 },
- { 198, 48 },
- { 140, 25 },
- { 281, 136 }
- }
- };
- extern const anim_t temp_epsd0animinfo[10];
- const anim_t temp_epsd0animinfo[10] =
- {
- { ANIM_ALWAYS, TICRATE/3, 3, { 224, 104 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 184, 160 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 112, 136 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 72, 112 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 88, 96 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 64, 48 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 192, 40 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 136, 16 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 80, 16 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 64, 24 } }
- };
- extern const anim_t temp_epsd1animinfo[9];
- const anim_t temp_epsd1animinfo[9] =
- {
- { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 1 },
- { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 2 },
- { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 3 },
- { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 4 },
- { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 5 },
- { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 6 },
- { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 7 },
- { ANIM_LEVEL, TICRATE/3, 3, { 192, 144 }, 8 },
- { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 8 }
- };
- extern const anim_t temp_epsd2animinfo[6];
- const anim_t temp_epsd2animinfo[6] =
- {
- { ANIM_ALWAYS, TICRATE/3, 3, { 104, 168 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 40, 136 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 160, 96 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 104, 80 } },
- { ANIM_ALWAYS, TICRATE/3, 3, { 120, 32 } },
- { ANIM_ALWAYS, TICRATE/4, 3, { 40, 0 } }
- };
-
- const wbplayerstruct_t* plrs;
- void localCalculateAchievements(bool epComplete)
- {
- if( !common->IsMultiplayer() ) {
- player_t *player = &::g->players[::g->consoleplayer];
-
- idAchievementManager::CheckDoomClassicsAchievements( player->killcount, player->itemcount, player->secretcount, ::g->gameskill, ::g->gamemission, ::g->gamemap, ::g->gameepisode, ::g->totalkills, ::g->totalitems, ::g->totalsecret );
- }
- }
- void WI_slamBackground(void)
- {
- memcpy(::g->screens[0], ::g->screens[1], SCREENWIDTH * SCREENHEIGHT);
- V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
- }
- qboolean WI_Responder(event_t* ev)
- {
- return false;
- }
- void WI_drawLF(void)
- {
- int y = WI_TITLEY;
-
- V_DrawPatch((ORIGINAL_WIDTH - SHORT(::g->lnames[::g->wbs->last]->width))/2,
- y, FB, ::g->lnames[::g->wbs->last]);
-
- y += (5*SHORT(::g->lnames[::g->wbs->last]->height))/4;
-
- V_DrawPatch((ORIGINAL_WIDTH - SHORT(::g->finished->width))/2,
- y, FB, ::g->finished);
- }
- void WI_drawEL(void)
- {
- int y = WI_TITLEY;
-
- V_DrawPatch((ORIGINAL_WIDTH - SHORT(::g->entering->width))/2,
- y, FB, ::g->entering);
-
- y += (5*SHORT(::g->lnames[::g->wbs->next]->height))/4;
- V_DrawPatch((ORIGINAL_WIDTH - SHORT(::g->lnames[::g->wbs->next]->width))/2,
- y, FB, ::g->lnames[::g->wbs->next]);
- }
- void
- WI_drawOnLnode
- ( int n,
- patch_t* c[] )
- {
- int i;
- int left;
- int top;
- int right;
- int bottom;
- qboolean fits = false;
- i = 0;
- do
- {
- left = lnodes[::g->wbs->epsd][n].x - SHORT(c[i]->leftoffset);
- top = lnodes[::g->wbs->epsd][n].y - SHORT(c[i]->topoffset);
- right = left + SHORT(c[i]->width);
- bottom = top + SHORT(c[i]->height);
- if (left >= 0
- && right < SCREENWIDTH
- && top >= 0
- && bottom < SCREENHEIGHT)
- {
- fits = true;
- }
- else
- {
- i++;
- }
- } while (!fits && i!=2);
- if (fits && i<2)
- {
- V_DrawPatch(lnodes[::g->wbs->epsd][n].x, lnodes[::g->wbs->epsd][n].y,
- FB, c[i]);
- }
- else
- {
-
- I_Printf("Could not place patch on level %d", n+1);
- }
- }
- void WI_initAnimatedBack(void)
- {
- int i;
- anim_t* a;
- if (::g->gamemode == commercial)
- return;
- if (::g->wbs->epsd > 2)
- return;
- for (i=0;i < ::g->NUMANIMS[::g->wbs->epsd];i++)
- {
- a = &::g->wi_stuff_anims[::g->wbs->epsd][i];
-
- a->ctr = -1;
-
- if (a->type == ANIM_ALWAYS)
- a->nexttic = ::g->bcnt + 1 + (M_Random()%a->period);
- else if (a->type == ANIM_RANDOM)
- a->nexttic = ::g->bcnt + 1 + a->data2+(M_Random()%a->data1);
- else if (a->type == ANIM_LEVEL)
- a->nexttic = ::g->bcnt + 1;
- }
- }
- void WI_updateAnimatedBack(void)
- {
- int i;
- anim_t* a;
- if (::g->gamemode == commercial)
- return;
- if (::g->wbs->epsd > 2)
- return;
- for (i=0;i < ::g->NUMANIMS[::g->wbs->epsd];i++)
- {
- a = &::g->wi_stuff_anims[::g->wbs->epsd][i];
- if (::g->bcnt == a->nexttic)
- {
- switch (a->type)
- {
- case ANIM_ALWAYS:
- if (++a->ctr >= a->nanims) a->ctr = 0;
- a->nexttic = ::g->bcnt + a->period;
- break;
- case ANIM_RANDOM:
- a->ctr++;
- if (a->ctr == a->nanims)
- {
- a->ctr = -1;
- a->nexttic = ::g->bcnt+a->data2+(M_Random()%a->data1);
- }
- else a->nexttic = ::g->bcnt + a->period;
- break;
-
- case ANIM_LEVEL:
-
- if (!(::g->state == StatCount && i == 7)
- && ::g->wbs->next == a->data1)
- {
- a->ctr++;
- if (a->ctr == a->nanims) a->ctr--;
- a->nexttic = ::g->bcnt + a->period;
- }
- break;
- }
- }
- }
- }
- void WI_drawAnimatedBack(void)
- {
- int i;
- anim_t* a;
- if (commercial)
- return;
- if (::g->wbs->epsd > 2)
- return;
- for (i=0 ; i < ::g->NUMANIMS[::g->wbs->epsd] ; i++)
- {
- a = &::g->wi_stuff_anims[::g->wbs->epsd][i];
- if (a->ctr >= 0)
- V_DrawPatch(a->loc.x, a->loc.y, FB, a->p[a->ctr]);
- }
- }
- int
- WI_drawNum
- ( int x,
- int y,
- int n,
- int digits )
- {
- int fontwidth = SHORT(::g->num[0]->width);
- int neg;
- int temp;
- if (digits < 0)
- {
- if (!n)
- {
-
- digits = 1;
- }
- else
- {
-
- digits = 0;
- temp = n;
- while (temp)
- {
- temp /= 10;
- digits++;
- }
- }
- }
- neg = n < 0;
- if (neg)
- n = -n;
-
- if (n == 1994)
- return 0;
-
- while (digits--)
- {
- x -= fontwidth;
- V_DrawPatch(x, y, FB, ::g->num[ n % 10 ]);
- n /= 10;
- }
-
- if (neg)
- V_DrawPatch(x-=8, y, FB, ::g->wiminus);
- return x;
- }
- void
- WI_drawPercent
- ( int x,
- int y,
- int p )
- {
- if (p < 0)
- return;
- V_DrawPatch(x, y, FB, ::g->percent);
- WI_drawNum(x, y, p, -1);
- }
- void
- WI_drawTime
- ( int x,
- int y,
- int t )
- {
- int div;
- int n;
- if (t<0)
- return;
- if (t <= 61*59)
- {
- div = 1;
- do
- {
- n = (t / div) % 60;
- x = WI_drawNum(x, y, n, 2) - SHORT(::g->colon->width);
- div *= 60;
-
- if (div==60 || t / div)
- V_DrawPatch(x, y, FB, ::g->colon);
-
- } while (t / div);
- }
- else
- {
-
- V_DrawPatch(x - SHORT(::g->sucks->width), y, FB, ::g->sucks);
- }
- }
- void WI_End(void)
- {
- void WI_unloadData(void);
- WI_unloadData();
- }
- void WI_initNoState(void)
- {
- ::g->state = NoState;
- ::g->acceleratestage = 0;
- ::g->cnt = 10;
- }
- void WI_updateNoState(void) {
- WI_updateAnimatedBack();
- if (!--::g->cnt) {
-
- WI_End();
- G_WorldDone();
- }
- DoomLib::ActivateGame();
- }
- void WI_initShowNextLoc(void)
- {
- ::g->state = ShowNextLoc;
- ::g->acceleratestage = 0;
- ::g->cnt = SHOWNEXTLOCDELAY * TICRATE;
- WI_initAnimatedBack();
- DoomLib::ActivateGame();
- }
- void WI_updateShowNextLoc(void)
- {
- WI_updateAnimatedBack();
- if (!--::g->cnt || ::g->acceleratestage) {
- WI_initNoState();
- DoomLib::ShowXToContinue( false );
- } else {
- ::g->snl_pointeron = (::g->cnt & 31) < 20;
- }
- }
- void WI_drawShowNextLoc(void)
- {
- int i;
- int last;
- WI_slamBackground();
-
- WI_drawAnimatedBack();
- if ( ::g->gamemode != commercial)
- {
- if (::g->wbs->epsd > 2)
- {
- WI_drawEL();
- return;
- }
-
- last = (::g->wbs->last == 8) ? ::g->wbs->next - 1 : ::g->wbs->last;
-
- if( last == 9 ) {
- for (i=0 ; i<MAXPLAYERS ; i++) {
- ::g->players[i].didsecret = false;
- }
- ::g->wbs->didsecret = false;
- last = -1;
- }
-
- for (i=0 ; i<=last ; i++)
- WI_drawOnLnode(i, &::g->splat);
-
- if (::g->wbs->didsecret)
- WI_drawOnLnode(8, &::g->splat);
-
- if (::g->snl_pointeron)
- WI_drawOnLnode(::g->wbs->next, ::g->yah);
- }
-
- if ( (::g->gamemode != commercial)
- || ::g->wbs->next != 30)
- WI_drawEL();
- }
- void WI_drawNoState(void)
- {
- ::g->snl_pointeron = true;
- WI_drawShowNextLoc();
- }
- int WI_fragSum(int playernum)
- {
- int i;
- int frags = 0;
-
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if ( i!=playernum)
- {
- frags += plrs[playernum].frags[i];
- }
- }
-
-
- frags -= plrs[playernum].frags[playernum];
-
-
- return frags;
- }
- int WI_fragOnlySum(int playernum)
- {
- int i;
- int frags = 0;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if ( i!=playernum)
- {
- frags += plrs[playernum].frags[i];
- }
- }
- return frags;
- }
- int WI_deathSum(int playernum)
- {
- int i;
- int deaths = 0;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if ( 1 )
- {
- deaths += plrs[i].frags[playernum];
- }
- }
- return deaths;
- }
- void WI_initDeathmatchStats(void)
- {
- int i;
- int j;
- ::g->state = StatCount;
- ::g->acceleratestage = 0;
- ::g->dm_state = 1;
- ::g->cnt_pause = TICRATE;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (::g->playeringame[i])
- {
- for (j=0 ; j<MAXPLAYERS ; j++)
- if (::g->playeringame[j])
- ::g->dm_frags[i][j] = 0;
- ::g->dm_totals[i] = 0;
- }
- }
-
- WI_initAnimatedBack();
- if ( common->IsMultiplayer() ) {
- localCalculateAchievements(false);
-
- }
- DoomLib::ShowXToContinue( true );
- }
- void WI_updateDeathmatchStats(void)
- {
- int i;
- int j;
-
- qboolean stillticking;
- WI_updateAnimatedBack();
- if (::g->acceleratestage && ::g->dm_state != 4)
- {
- ::g->acceleratestage = 0;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (::g->playeringame[i])
- {
- for (j=0 ; j<MAXPLAYERS ; j++)
- if (::g->playeringame[j])
- ::g->dm_frags[i][j] = plrs[i].frags[j];
- ::g->dm_totals[i] = WI_fragSum(i);
- }
- }
-
- S_StartSound(0, sfx_barexp);
- ::g->dm_state = 4;
- }
-
- if (::g->dm_state == 2)
- {
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
-
- stillticking = false;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (::g->playeringame[i])
- {
- for (j=0 ; j<MAXPLAYERS ; j++)
- {
- if (::g->playeringame[j]
- && ::g->dm_frags[i][j] != plrs[i].frags[j])
- {
- if (plrs[i].frags[j] < 0)
- ::g->dm_frags[i][j]--;
- else
- ::g->dm_frags[i][j]++;
- if (::g->dm_frags[i][j] > 99)
- ::g->dm_frags[i][j] = 99;
- if (::g->dm_frags[i][j] < -99)
- ::g->dm_frags[i][j] = -99;
-
- stillticking = true;
- }
- }
- ::g->dm_totals[i] = WI_fragSum(i);
- if (::g->dm_totals[i] > 99)
- ::g->dm_totals[i] = 99;
-
- if (::g->dm_totals[i] < -99)
- ::g->dm_totals[i] = -99;
- }
-
- }
- if (!stillticking)
- {
- S_StartSound(0, sfx_barexp);
- ::g->dm_state++;
- }
- }
- else if (::g->dm_state == 4)
- {
- if (::g->acceleratestage)
- {
- if ( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) ) {
-
-
-
- DoomLib::HandleEndMatch();
- }
- }
- }
- else if (::g->dm_state & 1)
- {
- if (!--::g->cnt_pause)
- {
- ::g->dm_state++;
- ::g->cnt_pause = TICRATE;
- }
- }
- }
- void WI_drawDeathmatchStats(void)
- {
- int i;
- int j;
- int x;
- int y;
- int w;
-
- int lh;
- lh = WI_SPACINGY;
- WI_slamBackground();
-
-
- WI_drawAnimatedBack();
- WI_drawLF();
-
- V_DrawPatch(DM_TOTALSX-SHORT(::g->total->width)/2,
- DM_MATRIXY-WI_SPACINGY+10,
- FB,
- ::g->total);
-
- V_DrawPatch(DM_KILLERSX, DM_KILLERSY, FB, ::g->killers);
- V_DrawPatch(DM_VICTIMSX, DM_VICTIMSY, FB, ::g->victims);
-
- x = DM_MATRIXX + DM_SPACINGX;
- y = DM_MATRIXY;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (::g->playeringame[i])
- {
- V_DrawPatch(x-SHORT(::g->wistuff_p[i]->width)/2,
- DM_MATRIXY - WI_SPACINGY,
- FB,
- ::g->wistuff_p[i]);
-
- V_DrawPatch(DM_MATRIXX-SHORT(::g->wistuff_p[i]->width)/2,
- y,
- FB,
- ::g->wistuff_p[i]);
-
- if (i == ::g->me )
- {
- V_DrawPatch(x-SHORT(::g->wistuff_p[i]->width)/2,
- DM_MATRIXY - WI_SPACINGY,
- FB,
- ::g->bstar);
- V_DrawPatch(DM_MATRIXX-SHORT(::g->wistuff_p[i]->width)/2,
- y,
- FB,
- ::g->star);
- }
- }
- else
- {
-
-
-
-
- }
- x += DM_SPACINGX;
- y += WI_SPACINGY;
- }
-
- y = DM_MATRIXY+10;
- w = SHORT(::g->num[0]->width);
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- x = DM_MATRIXX + DM_SPACINGX;
- if (::g->playeringame[i])
- {
- for (j=0 ; j<MAXPLAYERS ; j++)
- {
- if (::g->playeringame[j])
- WI_drawNum(x+w, y, ::g->dm_frags[i][j], 2);
- x += DM_SPACINGX;
- }
- WI_drawNum(DM_TOTALSX+w, y, ::g->dm_totals[i], 2);
- }
- y += WI_SPACINGY;
- }
- }
- void WI_initNetgameStats(void)
- {
- int i;
- ::g->state = StatCount;
- ::g->acceleratestage = 0;
- ::g->ng_state = 1;
- ::g->cnt_pause = TICRATE;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (!::g->playeringame[i])
- continue;
- ::g->cnt_kills[i] = ::g->cnt_items[i] = ::g->cnt_secret[i] = ::g->cnt_frags[i] = 0;
- ::g->dofrags += WI_fragSum(i);
- }
- ::g->dofrags = !!::g->dofrags;
- WI_initAnimatedBack();
-
-
- DoomLib::ShowXToContinue( true );
-
- }
- void WI_updateNetgameStats(void)
- {
- int i;
- int fsum;
-
- qboolean stillticking;
- WI_updateAnimatedBack();
- if (::g->acceleratestage && ::g->ng_state != 10)
- {
- ::g->acceleratestage = 0;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (!::g->playeringame[i])
- continue;
- ::g->cnt_kills[i] = (plrs[i].skills * 100) / ::g->wbs->maxkills;
- ::g->cnt_items[i] = (plrs[i].sitems * 100) / ::g->wbs->maxitems;
- ::g->cnt_secret[i] = (plrs[i].ssecret * 100) / ::g->wbs->maxsecret;
- if (::g->dofrags)
- ::g->cnt_frags[i] = WI_fragSum(i);
- }
- S_StartSound(0, sfx_barexp);
- ::g->ng_state = 10;
- }
- if (::g->ng_state == 2)
- {
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
- stillticking = false;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (!::g->playeringame[i])
- continue;
- ::g->cnt_kills[i] += 2;
- if (::g->cnt_kills[i] >= (plrs[i].skills * 100) / ::g->wbs->maxkills)
- ::g->cnt_kills[i] = (plrs[i].skills * 100) / ::g->wbs->maxkills;
- else
- stillticking = true;
- }
-
- if (!stillticking)
- {
- S_StartSound(0, sfx_barexp);
- ::g->ng_state++;
- }
- }
- else if (::g->ng_state == 4)
- {
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
- stillticking = false;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (!::g->playeringame[i])
- continue;
- ::g->cnt_items[i] += 2;
- if (::g->cnt_items[i] >= (plrs[i].sitems * 100) / ::g->wbs->maxitems)
- ::g->cnt_items[i] = (plrs[i].sitems * 100) / ::g->wbs->maxitems;
- else
- stillticking = true;
- }
- if (!stillticking)
- {
- S_StartSound(0, sfx_barexp);
- ::g->ng_state++;
- }
- }
- else if (::g->ng_state == 6)
- {
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
- stillticking = false;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (!::g->playeringame[i])
- continue;
- ::g->cnt_secret[i] += 2;
- if (::g->cnt_secret[i] >= (plrs[i].ssecret * 100) / ::g->wbs->maxsecret)
- ::g->cnt_secret[i] = (plrs[i].ssecret * 100) / ::g->wbs->maxsecret;
- else
- stillticking = true;
- }
-
- if (!stillticking)
- {
- S_StartSound(0, sfx_barexp);
- ::g->ng_state += 1 + 2*!::g->dofrags;
- }
- }
- else if (::g->ng_state == 8)
- {
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
- stillticking = false;
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (!::g->playeringame[i])
- continue;
- ::g->cnt_frags[i] += 1;
- if (::g->cnt_frags[i] >= (fsum = WI_fragSum(i)))
- ::g->cnt_frags[i] = fsum;
- else
- stillticking = true;
- }
-
- if (!stillticking)
- {
- S_StartSound(0, sfx_pldeth);
- ::g->ng_state++;
- }
- }
- else if (::g->ng_state == 10)
- {
- if (::g->acceleratestage)
- {
- if ( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) ) {
- S_StartSound(0, sfx_sgcock);
-
- localCalculateAchievements(false);
- if (::g->gamemode == commercial){
- WI_initNoState();
- DoomLib::ShowXToContinue( false );
- }
- else{
- WI_initShowNextLoc();
- }
- }
- }
- }
- else if (::g->ng_state & 1)
- {
- if (!--::g->cnt_pause)
- {
- ::g->ng_state++;
- ::g->cnt_pause = TICRATE;
- }
- }
- }
- void WI_drawNetgameStats(void)
- {
- int i;
- int x;
- int y;
- int pwidth = SHORT(::g->percent->width);
- WI_slamBackground();
-
-
- WI_drawAnimatedBack();
- WI_drawLF();
-
- V_DrawPatch(NG_STATSX+NG_SPACINGX-SHORT(::g->kills->width),
- NG_STATSY, FB, ::g->kills);
- V_DrawPatch(NG_STATSX+2*NG_SPACINGX-SHORT(::g->items->width),
- NG_STATSY, FB, ::g->items);
- V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(::g->secret->width),
- NG_STATSY, FB, ::g->secret);
-
- if (::g->dofrags)
- V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(::g->wistuff_frags->width),
- NG_STATSY, FB, ::g->wistuff_frags);
-
- y = NG_STATSY + SHORT(::g->kills->height);
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
- if (!::g->playeringame[i])
- continue;
- x = NG_STATSX;
- V_DrawPatch(x-SHORT(::g->wistuff_p[i]->width), y, FB, ::g->wistuff_p[i]);
-
- if (i == ::g->me )
- V_DrawPatch(x-SHORT(::g->wistuff_p[i]->width), y, FB, ::g->star);
- x += NG_SPACINGX;
- WI_drawPercent(x-pwidth, y+10, ::g->cnt_kills[i]); x += NG_SPACINGX;
- WI_drawPercent(x-pwidth, y+10, ::g->cnt_items[i]); x += NG_SPACINGX;
- WI_drawPercent(x-pwidth, y+10, ::g->cnt_secret[i]); x += NG_SPACINGX;
- if (::g->dofrags)
- WI_drawNum(x, y+10, ::g->cnt_frags[i], -1);
- y += WI_SPACINGY;
- }
- }
- void WI_initStats(void)
- {
- ::g->state = StatCount;
- ::g->acceleratestage = 0;
- ::g->sp_state = 1;
- ::g->cnt_kills[0] = ::g->cnt_items[0] = ::g->cnt_secret[0] = -1;
- ::g->cnt_time = ::g->cnt_par = -1;
- ::g->cnt_pause = TICRATE;
- WI_initAnimatedBack();
- DoomLib::ShowXToContinue( true );
- }
- void WI_updateStats(void)
- {
- WI_updateAnimatedBack();
- if (::g->acceleratestage && ::g->sp_state != 10)
- {
- ::g->acceleratestage = 0;
- ::g->cnt_kills[0] = (plrs[::g->me].skills * 100) / ::g->wbs->maxkills;
- ::g->cnt_items[0] = (plrs[::g->me].sitems * 100) / ::g->wbs->maxitems;
- ::g->cnt_secret[0] = (plrs[::g->me].ssecret * 100) / ::g->wbs->maxsecret;
- ::g->cnt_time = plrs[::g->me].stime / TICRATE;
- ::g->cnt_par = ::g->wbs->partime / TICRATE;
- S_StartSound(0, sfx_barexp);
- ::g->sp_state = 10;
- }
- if (::g->sp_state == 2)
- {
- ::g->cnt_kills[0] += 2;
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
- if (::g->cnt_kills[0] >= (plrs[::g->me].skills * 100) / ::g->wbs->maxkills)
- {
- ::g->cnt_kills[0] = (plrs[::g->me].skills * 100) / ::g->wbs->maxkills;
- S_StartSound(0, sfx_barexp);
- ::g->sp_state++;
- }
- }
- else if (::g->sp_state == 4)
- {
- ::g->cnt_items[0] += 2;
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
- if (::g->cnt_items[0] >= (plrs[::g->me].sitems * 100) / ::g->wbs->maxitems)
- {
- ::g->cnt_items[0] = (plrs[::g->me].sitems * 100) / ::g->wbs->maxitems;
- S_StartSound(0, sfx_barexp);
- ::g->sp_state++;
- }
- }
- else if (::g->sp_state == 6)
- {
- ::g->cnt_secret[0] += 2;
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
- if (::g->cnt_secret[0] >= (plrs[::g->me].ssecret * 100) / ::g->wbs->maxsecret)
- {
- ::g->cnt_secret[0] = (plrs[::g->me].ssecret * 100) / ::g->wbs->maxsecret;
- S_StartSound(0, sfx_barexp);
- ::g->sp_state++;
- }
- }
- else if (::g->sp_state == 8)
- {
- if (!(::g->bcnt&3))
- S_StartSound(0, sfx_pistol);
- ::g->cnt_time += 3;
- if (::g->cnt_time >= plrs[::g->me].stime / TICRATE)
- ::g->cnt_time = plrs[::g->me].stime / TICRATE;
- ::g->cnt_par += 3;
- if (::g->cnt_par >= ::g->wbs->partime / TICRATE)
- {
- ::g->cnt_par = ::g->wbs->partime / TICRATE;
- if (::g->cnt_time >= plrs[::g->me].stime / TICRATE)
- {
- S_StartSound(0, sfx_barexp);
- ::g->sp_state++;
- }
- }
- }
- else if (::g->sp_state == 10)
- {
- if (::g->acceleratestage)
- {
- if ( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) ) {
- S_StartSound(0, sfx_sgcock);
-
- localCalculateAchievements(false);
- if (::g->gamemode == commercial) {
- WI_initNoState();
- }
- else{
- WI_initShowNextLoc();
- }
- }
- }
- }
- else if (::g->sp_state & 1)
- {
- if (!--::g->cnt_pause)
- {
- ::g->sp_state++;
- ::g->cnt_pause = TICRATE;
- }
- }
- }
- void WI_drawStats(void)
- {
-
- int lh;
- lh = (3*SHORT(::g->num[0]->height))/2;
- WI_slamBackground();
-
- WI_drawAnimatedBack();
-
- WI_drawLF();
- V_DrawPatch(SP_STATSX, SP_STATSY, FB, ::g->kills);
- WI_drawPercent(ORIGINAL_WIDTH - SP_STATSX, SP_STATSY, ::g->cnt_kills[0]);
- V_DrawPatch(SP_STATSX, SP_STATSY+lh, FB, ::g->items);
- WI_drawPercent(ORIGINAL_WIDTH - SP_STATSX, SP_STATSY+lh, ::g->cnt_items[0]);
- V_DrawPatch(SP_STATSX, SP_STATSY+2*lh, FB, ::g->sp_secret);
- WI_drawPercent(ORIGINAL_WIDTH - SP_STATSX, SP_STATSY+2*lh, ::g->cnt_secret[0]);
- V_DrawPatch(SP_TIMEX, SP_TIMEY, FB, ::g->time);
- WI_drawTime(ORIGINAL_WIDTH/2 - SP_TIMEX, SP_TIMEY, ::g->cnt_time);
-
-
-
- V_DrawPatch(ORIGINAL_WIDTH/2 + SP_TIMEX, SP_TIMEY, FB, ::g->par);
- WI_drawTime(ORIGINAL_WIDTH - SP_TIMEX, SP_TIMEY, ::g->cnt_par);
-
- }
- void WI_checkForAccelerate(void)
- {
- int i;
- player_t *player;
-
- for (i=0, player = ::g->players ; i<MAXPLAYERS ; i++, player++)
- {
- if (::g->playeringame[i])
- {
- if (player->cmd.buttons & BT_ATTACK)
- {
- if (!player->attackdown) {
- ::g->acceleratestage = 1;
- }
- player->attackdown = true;
- } else {
- player->attackdown = false;
- }
- if (player->cmd.buttons & BT_USE)
- {
- if (!player->usedown) {
- ::g->acceleratestage = 1;
- }
- player->usedown = true;
-
- } else {
- player->usedown = false;
- }
- }
- }
- }
- void WI_Ticker(void)
- {
-
- ::g->bcnt++;
- if (::g->bcnt == 1)
- {
-
- if ( ::g->gamemode == commercial )
- S_ChangeMusic(mus_dm2int, true);
- else
- S_ChangeMusic(mus_inter, true);
- }
- WI_checkForAccelerate();
- switch (::g->state)
- {
- case StatCount:
- if (::g->deathmatch) WI_updateDeathmatchStats();
- else if (::g->netgame) WI_updateNetgameStats();
- else WI_updateStats();
- break;
-
- case ShowNextLoc:
- WI_updateShowNextLoc();
- break;
-
- case NoState:
- WI_updateNoState();
- break;
- }
- }
- void WI_loadData(void)
- {
- int i;
- int j;
- char name[9];
- anim_t* a;
- if (::g->gamemode == commercial)
- strcpy(name, "INTERPIC");
-
-
- else
- sprintf(name, "WIMAP%d", ::g->wbs->epsd);
- if ( ::g->gamemode == retail )
- {
- if (::g->wbs->epsd == 3)
- strcpy(name,"INTERPIC");
- }
-
- ::g->bg = (patch_t*)W_CacheLumpName(name, PU_LEVEL_SHARED);
- V_DrawPatch(0, 0, 1, ::g->bg);
-
-
-
-
-
-
-
-
-
-
- if (::g->gamemode == commercial)
- {
- ::g->NUMCMAPS = 32;
- ::g->lnames = (patch_t **) DoomLib::Z_Malloc(sizeof(patch_t*) * ::g->NUMCMAPS, PU_LEVEL_SHARED, 0);
- for (i=0 ; i < ::g->NUMCMAPS ; i++)
- {
- sprintf(name, "CWILV%2.2d", i);
- ::g->lnames[i] = (patch_t*)W_CacheLumpName(name, PU_LEVEL_SHARED);
- }
- }
- else
- {
- ::g->lnames = (patch_t **) DoomLib::Z_Malloc(sizeof(patch_t*) * ( NUMMAPS ), PU_LEVEL_SHARED, 0);
- for (i=0 ; i<NUMMAPS ; i++)
- {
- sprintf(name, "WILV%d%d", ::g->wbs->epsd, i);
- ::g->lnames[i] = (patch_t*)W_CacheLumpName(name, PU_LEVEL_SHARED);
- }
-
- ::g->yah[0] = (patch_t*)W_CacheLumpName("WIURH0", PU_LEVEL_SHARED);
-
- ::g->yah[1] = (patch_t*)W_CacheLumpName("WIURH1", PU_LEVEL_SHARED);
-
- ::g->splat = (patch_t*)W_CacheLumpName("WISPLAT", PU_LEVEL_SHARED);
-
- if (::g->wbs->epsd < 3)
- {
- for (j=0;j < ::g->NUMANIMS[::g->wbs->epsd];j++)
- {
- a = &::g->wi_stuff_anims[::g->wbs->epsd][j];
- for (i=0;i<a->nanims;i++)
- {
-
- if (::g->wbs->epsd != 1 || j != 8)
- {
-
- sprintf(name, "WIA%d%.2d%.2d", ::g->wbs->epsd, j, i);
- a->p[i] = (patch_t*)W_CacheLumpName(name, PU_LEVEL_SHARED);
- }
- else
- {
-
- a->p[i] = ::g->wi_stuff_anims[1][4].p[i];
- }
- }
- }
- }
- }
-
- ::g->wiminus = (patch_t*)W_CacheLumpName("WIMINUS", PU_LEVEL_SHARED);
- for (i=0;i<10;i++)
- {
-
- sprintf(name, "WINUM%d", i);
- ::g->num[i] = (patch_t*)W_CacheLumpName(name, PU_LEVEL_SHARED);
- }
-
- ::g->percent = (patch_t*)W_CacheLumpName("WIPCNT", PU_LEVEL_SHARED);
-
- ::g->finished = (patch_t*)W_CacheLumpName("WIF", PU_LEVEL_SHARED);
-
- ::g->entering = (patch_t*)W_CacheLumpName("WIENTER", PU_LEVEL_SHARED);
-
- ::g->kills = (patch_t*)W_CacheLumpName("WIOSTK", PU_LEVEL_SHARED);
-
- ::g->secret = (patch_t*)W_CacheLumpName("WIOSTS", PU_LEVEL_SHARED);
-
- ::g->sp_secret = (patch_t*)W_CacheLumpName("WISCRT2", PU_LEVEL_SHARED);
- ::g->items = (patch_t*)W_CacheLumpName("WIOSTI", PU_LEVEL_SHARED);
-
- ::g->wistuff_frags = (patch_t*)W_CacheLumpName("WIFRGS", PU_LEVEL_SHARED);
-
- ::g->colon = (patch_t*)W_CacheLumpName("WICOLON", PU_LEVEL_SHARED);
-
- ::g->time = (patch_t*)W_CacheLumpName("WITIME", PU_LEVEL_SHARED);
-
- ::g->sucks = (patch_t*)W_CacheLumpName("WISUCKS", PU_LEVEL_SHARED);
-
- ::g->par = (patch_t*)W_CacheLumpName("WIPAR", PU_LEVEL_SHARED);
-
- ::g->killers = (patch_t*)W_CacheLumpName("WIKILRS", PU_LEVEL_SHARED);
-
- ::g->victims = (patch_t*)W_CacheLumpName("WIVCTMS", PU_LEVEL_SHARED);
-
- ::g->total = (patch_t*)W_CacheLumpName("WIMSTT", PU_LEVEL_SHARED);
-
- ::g->star = (patch_t*)W_CacheLumpName("STFST01", PU_STATIC_SHARED);
-
- ::g->bstar = (patch_t*)W_CacheLumpName("STFDEAD0", PU_STATIC_SHARED);
- for (i=0 ; i<MAXPLAYERS ; i++)
- {
-
- sprintf(name, "STPB%d", i);
- ::g->wistuff_p[i] = (patch_t*)W_CacheLumpName(name, PU_LEVEL_SHARED);
-
- sprintf(name, "WIBP%d", i+1);
- ::g->wistuff_bp[i] = (patch_t*)W_CacheLumpName(name, PU_LEVEL_SHARED);
- }
- }
- void WI_unloadData(void)
- {
- Z_FreeTags( PU_LEVEL_SHARED, PU_LEVEL_SHARED );
-
- for (int i=0 ; i<MAXPLAYERS ; i++)
- {
- if (::g->playeringame[i])
- {
- ::g->players[i].mo = NULL;
- }
- }
- ::g->bg = NULL;
- }
- void WI_Drawer (void)
- {
- switch (::g->state)
- {
- case StatCount:
- if (::g->deathmatch)
- WI_drawDeathmatchStats();
- else if (::g->netgame)
- WI_drawNetgameStats();
- else
- WI_drawStats();
- break;
-
- case ShowNextLoc:
- WI_drawShowNextLoc();
- break;
-
- case NoState:
- WI_drawNoState();
- break;
- }
- }
- void WI_initVariables(wbstartstruct_t* wbstartstruct)
- {
- ::g->wbs = wbstartstruct;
- #ifdef RANGECHECKING
- if (::g->gamemode != commercial)
- {
- if ( ::g->gamemode == retail )
- RNGCHECK(::g->wbs->epsd, 0, 3);
- else
- RNGCHECK(::g->wbs->epsd, 0, 2);
- }
- else
- {
- RNGCHECK(::g->wbs->last, 0, 8);
- RNGCHECK(::g->wbs->next, 0, 8);
- }
- RNGCHECK(::g->wbs->pnum, 0, MAXPLAYERS);
- RNGCHECK(::g->wbs->pnum, 0, MAXPLAYERS);
- #endif
- ::g->acceleratestage = 0;
- ::g->cnt = ::g->bcnt = 0;
- ::g->firstrefresh = 1;
- ::g->me = ::g->wbs->pnum;
- plrs = ::g->wbs->plyr;
- if (!::g->wbs->maxkills)
- ::g->wbs->maxkills = 1;
- if (!::g->wbs->maxitems)
- ::g->wbs->maxitems = 1;
- if (!::g->wbs->maxsecret)
- ::g->wbs->maxsecret = 1;
- if ( ::g->gamemode != retail )
- if (::g->wbs->epsd > 2)
- ::g->wbs->epsd -= 3;
- }
- void WI_Start(wbstartstruct_t* wbstartstruct)
- {
- WI_initVariables(wbstartstruct);
- WI_loadData();
- if (::g->deathmatch)
- WI_initDeathmatchStats();
- else if (::g->netgame)
- WI_initNetgameStats();
- else
- WI_initStats();
- }
|