Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Iskhodnyy_kod_Doom

.pdf
Скачиваний:
7
Добавлен:
13.02.2015
Размер:
1.01 Mб
Скачать

if (!(bcnt&3))

S_StartSound(0, sfx_pistol);

if (cnt_kills[0] >= (plrs[me].skills * 100) / wbs->maxkills)

{

cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; S_StartSound(0, sfx_barexp);

sp_state++;

}

}

else if (sp_state == 4)

{

cnt_items[0] += 2;

if (!(bcnt&3))

S_StartSound(0, sfx_pistol);

if (cnt_items[0] >= (plrs[me].sitems * 100) / wbs->maxitems)

{

cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; S_StartSound(0, sfx_barexp);

sp_state++;

}

}

else if (sp_state == 6)

{

cnt_secret[0] += 2;

if (!(bcnt&3))

S_StartSound(0, sfx_pistol);

if (cnt_secret[0] >= (plrs[me].ssecret * 100) / wbs->maxsecret)

{

cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret; S_StartSound(0, sfx_barexp);

sp_state++;

}

}

else if (sp_state == 8)

{

if (!(bcnt&3))

S_StartSound(0, sfx_pistol);

cnt_time += 3;

if (cnt_time >= plrs[me].stime / TICRATE) cnt_time = plrs[me].stime / TICRATE;

cnt_par += 3;

if (cnt_par >= wbs->partime / TICRATE)

{

cnt_par = wbs->partime / TICRATE;

if (cnt_time >= plrs[me].stime / TICRATE)

{

S_StartSound(0, sfx_barexp); sp_state++;

}

}

}

else if (sp_state == 10)

{

if (acceleratestage)

801

{

S_StartSound(0, sfx_sgcock);

if (gamemode == commercial) WI_initNoState();

else

WI_initShowNextLoc();

}

}

else if (sp_state & 1)

{

if (!--cnt_pause)

{

sp_state++; cnt_pause = TICRATE;

}

}

}

void WI_drawStats(void)

{

// line height int lh;

lh = (3*SHORT(num[0]->height))/2;

WI_slamBackground();

// draw animated background WI_drawAnimatedBack();

WI_drawLF();

V_DrawPatch(SP_STATSX, SP_STATSY, FB, kills); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]);

V_DrawPatch(SP_STATSX, SP_STATSY+lh, FB, items); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+lh, cnt_items[0]);

V_DrawPatch(SP_STATSX, SP_STATSY+2*lh, FB, sp_secret); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]);

V_DrawPatch(SP_TIMEX, SP_TIMEY, FB, time); WI_drawTime(SCREENWIDTH/2 - SP_TIMEX, SP_TIMEY, cnt_time);

if (wbs->epsd < 3)

{

V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, FB, par); WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par);

}

}

void WI_checkForAccelerate(void)

{

int i;

player_t *player;

// check for button presses to skip delays

for (i=0, player = players ; i<MAXPLAYERS ; i++, player++)

{

if (playeringame[i])

{

if (player->cmd.buttons & BT_ATTACK)

802

{

if (!player->attackdown) acceleratestage = 1;

player->attackdown = true;

}

else

player->attackdown = false; if (player->cmd.buttons & BT_USE)

{

if (!player->usedown) acceleratestage = 1;

player->usedown = true;

}

else

player->usedown = false;

}

}

}

// Updates stuff each tick void WI_Ticker(void)

{

// counter for general background animation bcnt++;

if (bcnt == 1)

{

// intermission music

if ( gamemode == commercial ) S_ChangeMusic(mus_dm2int, true);

else

S_ChangeMusic(mus_inter, true);

}

WI_checkForAccelerate();

switch (state)

{

case StatCount:

if (deathmatch) WI_updateDeathmatchStats(); else if (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 (gamemode == commercial)

803

strcpy(name, "INTERPIC");

else

sprintf(name, "WIMAP%d", wbs->epsd);

if ( gamemode == retail )

{

if (wbs->epsd == 3) strcpy(name,"INTERPIC");

}

// background

bg = W_CacheLumpName(name, PU_CACHE); V_DrawPatch(0, 0, 1, bg);

//UNUSED unsigned char *pic = screens[1];

//if (gamemode == commercial)

//{

//darken the background image

//while (pic != screens[1] + SCREENHEIGHT*SCREENWIDTH)

//{

//*pic = colormaps[256*25 + *pic];

//pic++;

//}

//}

if (gamemode == commercial)

{

NUMCMAPS = 32;

lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMCMAPS, PU_STATIC, 0);

for (i=0 ; i<NUMCMAPS ; i++)

{

sprintf(name, "CWILV%2.2d", i);

lnames[i] = W_CacheLumpName(name, PU_STATIC);

}

}

else

{

lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMMAPS, PU_STATIC, 0);

for (i=0 ; i<NUMMAPS ; i++)

{

sprintf(name, "WILV%d%d", wbs->epsd, i); lnames[i] = W_CacheLumpName(name, PU_STATIC);

}

// you are here

yah[0] = W_CacheLumpName("WIURH0", PU_STATIC);

// you are here (alt.)

yah[1] = W_CacheLumpName("WIURH1", PU_STATIC);

// splat

splat = W_CacheLumpName("WISPLAT", PU_STATIC);

if (wbs->epsd < 3)

{

for (j=0;j<NUMANIMS[wbs->epsd];j++)

{

a = &anims[wbs->epsd][j]; for (i=0;i<a->nanims;i++)

{

// MONDO HACK!

if (wbs->epsd != 1 || j != 8)

804

{

// animations

sprintf(name, "WIA%d%.2d%.2d", wbs->epsd, j, i); a->p[i] = W_CacheLumpName(name, PU_STATIC);

}

else

{

// HACK ALERT!

a->p[i] = anims[1][4].p[i];

}

}

}

}

}

// More hacks on minus sign.

wiminus = W_CacheLumpName("WIMINUS", PU_STATIC);

for (i=0;i<10;i++)

{

// numbers 0-9 sprintf(name, "WINUM%d", i);

num[i] = W_CacheLumpName(name, PU_STATIC);

}

// percent sign

percent = W_CacheLumpName("WIPCNT", PU_STATIC);

// "finished"

finished = W_CacheLumpName("WIF", PU_STATIC);

// "entering"

entering = W_CacheLumpName("WIENTER", PU_STATIC);

// "kills"

kills = W_CacheLumpName("WIOSTK", PU_STATIC);

// "scrt"

secret = W_CacheLumpName("WIOSTS", PU_STATIC);

// "secret"

sp_secret = W_CacheLumpName("WISCRT2", PU_STATIC);

// Yuck.

if (french)

{

// "items"

if (netgame && !deathmatch)

items = W_CacheLumpName("WIOBJ", PU_STATIC); else

items = W_CacheLumpName("WIOSTI", PU_STATIC);

} else

items = W_CacheLumpName("WIOSTI", PU_STATIC);

// "frgs"

frags = W_CacheLumpName("WIFRGS", PU_STATIC);

// ":"

colon = W_CacheLumpName("WICOLON", PU_STATIC);

// "time"

time = W_CacheLumpName("WITIME", PU_STATIC);

// "sucks"

sucks = W_CacheLumpName("WISUCKS", PU_STATIC);

805

// "par"

par = W_CacheLumpName("WIPAR", PU_STATIC);

// "killers" (vertical)

killers = W_CacheLumpName("WIKILRS", PU_STATIC);

// "victims" (horiz)

victims = W_CacheLumpName("WIVCTMS", PU_STATIC);

// "total"

total = W_CacheLumpName("WIMSTT", PU_STATIC);

// your face

star = W_CacheLumpName("STFST01", PU_STATIC);

// dead face

bstar = W_CacheLumpName("STFDEAD0", PU_STATIC);

for (i=0 ; i<MAXPLAYERS ; i++)

{

// "1,2,3,4"

sprintf(name, "STPB%d", i);

p[i] = W_CacheLumpName(name, PU_STATIC);

// "1,2,3,4"

sprintf(name, "WIBP%d", i+1);

bp[i] = W_CacheLumpName(name, PU_STATIC);

}

}

void WI_unloadData(void)

{

int

i;

int

j;

Z_ChangeTag(wiminus, PU_CACHE);

for (i=0 ; i<10 ; i++) Z_ChangeTag(num[i], PU_CACHE);

if (gamemode == commercial)

{

for (i=0 ; i<NUMCMAPS ; i++) Z_ChangeTag(lnames[i], PU_CACHE);

}

else

{

Z_ChangeTag(yah[0], PU_CACHE);

Z_ChangeTag(yah[1], PU_CACHE);

Z_ChangeTag(splat, PU_CACHE);

for (i=0 ; i<NUMMAPS ; i++) Z_ChangeTag(lnames[i], PU_CACHE);

if (wbs->epsd < 3)

{

for (j=0;j<NUMANIMS[wbs->epsd];j++)

{

if (wbs->epsd != 1 || j != 8)

for (i=0;i<anims[wbs->epsd][j].nanims;i++) Z_ChangeTag(anims[wbs->epsd][j].p[i], PU_CACHE);

}

806

}

}

Z_Free(lnames);

Z_ChangeTag(percent, PU_CACHE);

Z_ChangeTag(colon, PU_CACHE);

Z_ChangeTag(finished, PU_CACHE);

Z_ChangeTag(entering, PU_CACHE);

Z_ChangeTag(kills, PU_CACHE);

Z_ChangeTag(secret, PU_CACHE);

Z_ChangeTag(sp_secret, PU_CACHE);

Z_ChangeTag(items, PU_CACHE);

Z_ChangeTag(frags, PU_CACHE);

Z_ChangeTag(time, PU_CACHE);

Z_ChangeTag(sucks, PU_CACHE);

Z_ChangeTag(par, PU_CACHE);

Z_ChangeTag(victims, PU_CACHE);

Z_ChangeTag(killers, PU_CACHE);

Z_ChangeTag(total, PU_CACHE);

//Z_ChangeTag(star, PU_CACHE);

//Z_ChangeTag(bstar, PU_CACHE);

for (i=0 ; i<MAXPLAYERS ; i++) Z_ChangeTag(p[i], PU_CACHE);

for (i=0 ; i<MAXPLAYERS ; i++) Z_ChangeTag(bp[i], PU_CACHE);

}

void WI_Drawer (void)

{

switch (state)

{

case StatCount: if (deathmatch)

WI_drawDeathmatchStats(); else if (netgame)

WI_drawNetgameStats();

else

WI_drawStats(); break;

case ShowNextLoc: WI_drawShowNextLoc(); break;

case NoState: WI_drawNoState(); break;

}

}

void WI_initVariables(wbstartstruct_t* wbstartstruct)

{

wbs = wbstartstruct;

#ifdef RANGECHECKING

if (gamemode != commercial)

{

if ( gamemode == retail ) RNGCHECK(wbs->epsd, 0, 3);

807

else

RNGCHECK(wbs->epsd, 0, 2);

}

else

{

RNGCHECK(wbs->last, 0, 8);

RNGCHECK(wbs->next, 0, 8);

}

RNGCHECK(wbs->pnum, 0, MAXPLAYERS);

RNGCHECK(wbs->pnum, 0, MAXPLAYERS); #endif

acceleratestage = 0; cnt = bcnt = 0; firstrefresh = 1;

me = wbs->pnum; plrs = wbs->plyr;

if (!wbs->maxkills) wbs->maxkills = 1;

if (!wbs->maxitems) wbs->maxitems = 1;

if (!wbs->maxsecret) wbs->maxsecret = 1;

if ( gamemode != retail ) if (wbs->epsd > 2)

wbs->epsd -= 3;

}

void WI_Start(wbstartstruct_t* wbstartstruct)

{

WI_initVariables(wbstartstruct);

WI_loadData();

if (deathmatch) WI_initDeathmatchStats();

else if (netgame) WI_initNetgameStats();

else

WI_initStats();

}

15.2 wi stu .h

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This source is available for distribution and/or modification

//only under the terms of the DOOM Source Code License as

//published by id Software. All rights reserved.

//

//The source is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License

//for more details.

//

// DESCRIPTION:

808

// Intermission.

//

//-----------------------------------------------------------------------------

#ifndef __WI_STUFF__ #define __WI_STUFF__

//#include "v_video.h"

#include "doomdef.h"

// States for the intermission

typedef enum

{

NoState = -1,

StatCount,

ShowNextLoc

} stateenum_t;

//Called by main loop, animate the intermission. void WI_Ticker (void);

//Called by main loop,

//draws the intermission directly into the screen buffer. void WI_Drawer (void);

//Setup for an intermission screen.

void WI_Start(wbstartstruct_t*

wbstartstruct);

#endif

 

//-----------------------------------------------------------------------------

 

//

 

// $Log:$

 

//

 

//-----------------------------------------------------------------------------

 

16 Zone memory allocation system

16.1 z zone.c

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This source is available for distribution and/or modification

//only under the terms of the DOOM Source Code License as

//published by id Software. All rights reserved.

//

//The source is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License

//for more details.

//

//$Log:$

//DESCRIPTION:

//Zone Memory Allocation. Neat.

//-----------------------------------------------------------------------------

809

static const char

rcsid[] = "$Id: z_zone.c,v 1.4 1997/02/03 16:47:58 b1 Exp $";

#include "z_zone.h" #include "i_system.h" #include "doomdef.h"

//

//ZONE MEMORY ALLOCATION

//There is never any space between memblocks,

//and there will never be two contiguous free memblocks.

//The rover can be left pointing at a non-empty block.

//

//It is of no value to free a cachable block,

//because it will get overwritten automatically if needed.

#define ZONEID

0x1d4a11

typedef struct

{

// total

bytes malloced, including header

int

 

size;

// start

/ end cap for linked list

memblock_t

blocklist;

memblock_t*

rover;

} memzone_t;

 

 

memzone_t*

 

mainzone;

//

// Z_ClearZone

//

void Z_ClearZone (memzone_t* zone)

{

memblock_t*

block;

// set the entire zone to one free block zone->blocklist.next =

zone->blocklist.prev =

block = (memblock_t *)( (byte *)zone + sizeof(memzone_t) );

zone->blocklist.user = (void *)zone; zone->blocklist.tag = PU_STATIC; zone->rover = block;

block->prev = block->next = &zone->blocklist;

// NULL indicates a free block. block->user = NULL;

block->size = zone->size - sizeof(memzone_t);

}

810

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]