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

Iskhodnyy_kod_Doom

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

}

void STlib_initMultIcon

( st_multicon_t*

i,

int

x,

int

y,

patch_t**

il,

int*

inum,

boolean*

on )

{

 

i->x

= x;

i->y

= y;

i->oldinum

= -1;

i->inum

= inum;

i->on

= on;

i->p

= il;

}

 

void

 

STlib_updateMultIcon

 

( st_multicon_t*

mi,

boolean

refresh )

{

 

int

w;

int

h;

int

x;

int

y;

if (*mi->on

&&(mi->oldinum != *mi->inum || refresh)

&&(*mi->inum!=-1))

{

if (mi->oldinum != -1)

{

x = mi->x - SHORT(mi->p[mi->oldinum]->leftoffset); y = mi->y - SHORT(mi->p[mi->oldinum]->topoffset); w = SHORT(mi->p[mi->oldinum]->width);

h = SHORT(mi->p[mi->oldinum]->height);

if (y - ST_Y < 0)

I_Error("updateMultIcon: y - ST_Y < 0");

V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG);

}

V_DrawPatch(mi->x, mi->y, FG, mi->p[*mi->inum]); mi->oldinum = *mi->inum;

}

}

void

 

STlib_initBinIcon

 

( st_binicon_t*

b,

int

x,

int

y,

patch_t*

i,

boolean*

val,

boolean*

on )

{

 

731

b->x

= x;

b->y

= y;

b->oldval

= 0;

b->val

= val;

b->on

= on;

b->p

= i;

}

 

void

 

STlib_updateBinIcon

 

( st_binicon_t*

bi,

boolean

refresh )

{

 

int

x;

int

y;

int

w;

int

h;

if (*bi->on

&& (bi->oldval != *bi->val || refresh))

{

x = bi->x - SHORT(bi->p->leftoffset); y = bi->y - SHORT(bi->p->topoffset); w = SHORT(bi->p->width);

h = SHORT(bi->p->height);

if (y - ST_Y < 0)

I_Error("updateBinIcon: y - ST_Y < 0");

if (*bi->val)

V_DrawPatch(bi->x, bi->y, FG, bi->p);

else

V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG);

bi->oldval = *bi->val;

}

}

12.2st lib.h

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

//

//$Id:$

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

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

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

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//DESCRIPTION:

//The status bar widget code.

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

732

#ifndef __STLIB__ #define __STLIB__

// We are referring to patches. #include "r_defs.h"

//

// Background and foreground screen numbers

//

#define BG 4 #define FG 0

//

//Typedefs of widgets

//Number widget

typedef struct

{

//upper right-hand corner

//of the number (right-justified)

int

x;

int

y;

//max # of digits in number int width;

//last number value

int oldnum;

// pointer to current value int* num;

//pointer to boolean stating

//whether to update number

boolean* on;

// list of patches for 0-9 patch_t** p;

// user data int data;

} st_number_t;

//Percent widget ("child" of number widget,

//or, more precisely, contains a number widget.) typedef struct

{

//number information

st_number_t

n;

// percent sign graphic

 

patch_t*

p;

} st_percent_t;

 

733

// Multiple Icon widget

typedef

struct

{

 

//

center-justified location of icons

int

x;

int

y;

// last icon number

int

oldinum;

// pointer to current icon

int*

inum;

//pointer to boolean stating

//whether to update icon

boolean*

on;

// list of icons

 

patch_t**

p;

// user data

 

int

data;

} st_multicon_t;

 

// Binary Icon widget

typedef struct

{

// center-justified location of icon

int

x;

int

y;

// last icon value

 

int

oldval;

// pointer to current icon status

boolean* val;

//pointer to boolean

//stating whether to update icon

boolean*

on;

 

patch_t*

p;

// icon

int

data;

// user data

} st_binicon_t;

 

 

//

//Widget creation, access, and update routines

//Initializes widget library.

//More precisely, initialize STMINUS,

//everything else is done somewhere else.

//

void STlib_init(void);

734

// Number widget routines

void

 

STlib_initNum

 

( st_number_t*

n,

int

x,

int

y,

patch_t**

pl,

int*

num,

boolean*

on,

int

width );

void

 

STlib_updateNum

 

( st_number_t*

n,

boolean

refresh );

// Percent widget routines

void

 

STlib_initPercent

 

( st_percent_t*

p,

int

x,

int

y,

patch_t**

pl,

int*

num,

boolean*

on,

patch_t*

percent );

void

 

STlib_updatePercent

 

( st_percent_t*

per,

int

refresh );

// Multiple Icon widget routines

void

 

STlib_initMultIcon

 

( st_multicon_t*

mi,

int

x,

int

y,

patch_t**

il,

int*

inum,

boolean*

on );

void

 

STlib_updateMultIcon

 

( st_multicon_t*

mi,

boolean

refresh );

// Binary Icon widget routines

void

 

STlib_initBinIcon

 

( st_binicon_t*

b,

int

x,

int

y,

patch_t*

i,

boolean*

val,

boolean*

on );

735

void

 

STlib_updateBinIcon

 

( st_binicon_t*

bi,

boolean

refresh );

#endif

 

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

 

//

 

// $Log:$

 

//

 

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

 

12.3 st stu .c

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

//

//$Id:$

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

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

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

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//$Log:$

//DESCRIPTION:

//Status bar code.

//Does the face/direction indicator animatin.

//Does palette indicators as well (red pain/berserk, bright pickup)

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

static const char

rcsid[] = "$Id: st_stuff.c,v 1.6 1997/02/03 22:45:13 b1 Exp $";

#include <stdio.h>

#include "i_system.h" #include "i_video.h" #include "z_zone.h"

#include "m_random.h" #include "w_wad.h"

#include "doomdef.h"

#include "g_game.h"

#include "st_stuff.h" #include "st_lib.h" #include "r_local.h"

#include "p_local.h" #include "p_inter.h"

#include "am_map.h" #include "m_cheat.h"

736

#include "s_sound.h"

//Needs access to LFB. #include "v_video.h"

//State.

#include "doomstat.h"

// Data.

#include "dstrings.h" #include "sounds.h"

//

//STATUS BAR DATA

//Palette indices.

//For damage/bonus red-/gold-shifts

#define STARTREDPALS

1

#define STARTBONUSPALS

9

#define NUMREDPALS

8

#define NUMBONUSPALS

4

// Radiation suit, green shift.

 

#define RADIATIONPAL

13

//N/256*100% probability

//that the normal face state will change

#define ST_FACEPROBABILITY

96

// For Responder

 

#define ST_TOGGLECHAT

KEY_ENTER

// Location of status bar

 

#define ST_X

0

#define ST_X2

104

#define ST_FX

143

#define ST_FY

169

//Should be set to patch width

//for tall numbers later on

#define ST_TALLNUMWIDTH

(tallnum[0]->width)

// Number of status faces.

 

#define ST_NUMPAINFACES

5

#define ST_NUMSTRAIGHTFACES

3

#define ST_NUMTURNFACES

2

#define ST_NUMSPECIALFACES

3

#define ST_FACESTRIDE \

(ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES)

#define ST_NUMEXTRAFACES

2

#define ST_NUMFACES \

(ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES)

#define ST_TURNOFFSET

(ST_NUMSTRAIGHTFACES)

#define ST_OUCHOFFSET

(ST_TURNOFFSET + ST_NUMTURNFACES)

#define ST_EVILGRINOFFSET

(ST_OUCHOFFSET + 1)

#define ST_RAMPAGEOFFSET

(ST_EVILGRINOFFSET + 1)

#define ST_GODFACE

(ST_NUMPAINFACES*ST_FACESTRIDE)

#define ST_DEADFACE

(ST_GODFACE+1)

737

#define ST_FACESX

143

#define ST_FACESY

168

#define ST_EVILGRINCOUNT

(2*TICRATE)

#define ST_STRAIGHTFACECOUNT

(TICRATE/2)

#define ST_TURNCOUNT

(1*TICRATE)

#define ST_OUCHCOUNT

(1*TICRATE)

#define ST_RAMPAGEDELAY

(2*TICRATE)

#define ST_MUCHPAIN

20

//Location and size of statistics,

//justified according to widget type.

//Problem is, within which space? STbar? Screen?

//Note: this could be read in by a lump.

//Problem is, is the stuff rendered

//into a buffer,

//or into the frame buffer?

//AMMO number pos.

#define ST_AMMOWIDTH

3

#define ST_AMMOX

44

#define ST_AMMOY

171

// HEALTH number pos.

 

#define ST_HEALTHWIDTH

3

#define ST_HEALTHX

90

#define ST_HEALTHY

171

// Weapon pos.

 

#define ST_ARMSX

111

#define ST_ARMSY

172

#define ST_ARMSBGX

104

#define ST_ARMSBGY

168

#define ST_ARMSXSPACE

12

#define ST_ARMSYSPACE

10

// Frags pos.

 

#define ST_FRAGSX

138

#define ST_FRAGSY

171

#define ST_FRAGSWIDTH

2

// ARMOR number pos.

 

#define ST_ARMORWIDTH

3

#define ST_ARMORX

221

#define ST_ARMORY

171

// Key icon positions.

 

#define ST_KEY0WIDTH

8

#define ST_KEY0HEIGHT

5

#define ST_KEY0X

239

#define ST_KEY0Y

171

#define ST_KEY1WIDTH

ST_KEY0WIDTH

#define ST_KEY1X

239

#define ST_KEY1Y

181

#define ST_KEY2WIDTH

ST_KEY0WIDTH

#define ST_KEY2X

239

#define ST_KEY2Y

191

// Ammunition counter.

 

#define ST_AMMO0WIDTH

3

#define ST_AMMO0HEIGHT

6

#define ST_AMMO0X

288

738

#define ST_AMMO0Y

173

#define ST_AMMO1WIDTH

ST_AMMO0WIDTH

#define ST_AMMO1X

288

#define ST_AMMO1Y

179

#define ST_AMMO2WIDTH

ST_AMMO0WIDTH

#define ST_AMMO2X

288

#define ST_AMMO2Y

191

#define ST_AMMO3WIDTH

ST_AMMO0WIDTH

#define ST_AMMO3X

288

#define ST_AMMO3Y

185

//Indicate maximum ammunition.

//Only needed because backpack exists.

#define

ST_MAXAMMO0WIDTH

3

#define

ST_MAXAMMO0HEIGHT

5

#define

ST_MAXAMMO0X

314

#define

ST_MAXAMMO0Y

173

#define

ST_MAXAMMO1WIDTH

ST_MAXAMMO0WIDTH

#define

ST_MAXAMMO1X

314

#define

ST_MAXAMMO1Y

179

#define

ST_MAXAMMO2WIDTH

ST_MAXAMMO0WIDTH

#define

ST_MAXAMMO2X

314

#define

ST_MAXAMMO2Y

191

#define

ST_MAXAMMO3WIDTH

ST_MAXAMMO0WIDTH

#define

ST_MAXAMMO3X

314

#define

ST_MAXAMMO3Y

185

// pistol

 

#define

ST_WEAPON0X

110

#define

ST_WEAPON0Y

172

// shotgun

 

#define

ST_WEAPON1X

122

#define

ST_WEAPON1Y

172

// chain gun

 

#define

ST_WEAPON2X

134

#define

ST_WEAPON2Y

172

// missile launcher

 

#define

ST_WEAPON3X

110

#define

ST_WEAPON3Y

181

// plasma gun

 

#define

ST_WEAPON4X

122

#define

ST_WEAPON4Y

181

// bfg

 

 

#define

ST_WEAPON5X

134

#define

ST_WEAPON5Y

181

// WPNS

title

 

#define

ST_WPNSX

109

#define

ST_WPNSY

191

// DETH title

 

#define

ST_DETHX

109

#define

ST_DETHY

191

//Incoming messages window location

//UNUSED

 

 

// #define ST_MSGTEXTX

(viewwindowx)

// #define ST_MSGTEXTY

(viewwindowy+viewheight-18)

#define

ST_MSGTEXTX

0

#define

ST_MSGTEXTY

0

739

// Dimensions given in characters.

#define

ST_MSGWIDTH

 

52

// Or shall I say, in lines?

#define

ST_MSGHEIGHT

 

1

#define

ST_OUTTEXTX

 

0

#define

ST_OUTTEXTY

 

6

// Width, in characters again.

#define

ST_OUTWIDTH

 

52

// Height, in lines.

 

 

#define

ST_OUTHEIGHT

 

1

#define

ST_MAPWIDTH

 

\

(strlen(mapnames[(gameepisode-1)*9+(gamemap-1)]))

#define

ST_MAPTITLEX \

 

 

(SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH)

#define

ST_MAPTITLEY

 

0

#define

ST_MAPHEIGHT

 

1

// main

player in game

 

 

static player_t*

plyr;

// ST_Start() has just been called

static boolean

 

st_firsttime;

// used

to execute ST_Init() only once

static int

 

veryfirsttime = 1;

// lump

number for PLAYPAL

 

static int

 

lu_palette;

// used

for timing

 

 

static unsigned int

 

st_clock;

// used

for making messages go away

static int

 

st_msgcounter=0;

// used

when in chat

 

 

static st_chatstateenum_t

st_chatstate;

// whether in automap or first-person

static st_stateenum_t

 

st_gamestate;

// whether left-side main status bar is active

static boolean

 

st_statusbaron;

// whether status bar chat is active

static boolean

 

st_chat;

// value of st_chat before message popped up

static boolean

 

st_oldchat;

// whether chat window has the cursor on

static boolean

 

st_cursoron;

// !deathmatch

 

 

static boolean

 

st_notdeathmatch;

// !deathmatch && st_statusbaron

static boolean

 

st_armson;

740

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