diff options
author | James Haley | 2011-02-14 02:21:42 +0000 |
---|---|---|
committer | James Haley | 2011-02-14 02:21:42 +0000 |
commit | 63903f9aac430d321a3063fbc79d61ccae6db22e (patch) | |
tree | 01b4a185fd2aad40b7427ac8c98ef89764bdd9d2 | |
parent | 4c4a67ef7ad1b53d5b13e37e2ff3744320a0f1ac (diff) | |
download | chocolate-doom-63903f9aac430d321a3063fbc79d61ccae6db22e.tar.gz chocolate-doom-63903f9aac430d321a3063fbc79d61ccae6db22e.tar.bz2 chocolate-doom-63903f9aac430d321a3063fbc79d61ccae6db22e.zip |
Fix to HUlib_drawYellowText (more Hex-Rays code-skipping shenanigans),
and finished ST_drawKeysPopup for drawing keys (TODO: in deathmatch it
draws frags instead). Fix to buffer overflow in V_ScreenShot - *ATTN
fraggle* - needs fix in trunk!
Subversion-branch: /branches/strife-branch
Subversion-revision: 2265
-rw-r--r-- | src/strife/hu_lib.c | 52 | ||||
-rw-r--r-- | src/strife/st_stuff.c | 181 | ||||
-rw-r--r-- | src/v_video.c | 2 |
3 files changed, 144 insertions, 91 deletions
diff --git a/src/strife/hu_lib.c b/src/strife/hu_lib.c index 2033c7b5..6d29115b 100644 --- a/src/strife/hu_lib.c +++ b/src/strife/hu_lib.c @@ -47,7 +47,7 @@ extern boolean D_PatchClipCallback(patch_t *patch, int x, int y); // [STRIFE] // // HUlib_drawYellowText // -// haleyjd 09/18/10: [STRIFE] New function. +// haleyjd 20100918: [STRIFE] New function. // void HUlib_drawYellowText(int x, int y, char *text) { @@ -61,37 +61,43 @@ void HUlib_drawYellowText(int x, int y, char *text) { x = start_x; y += 12; + continue; } - else if(c == '_' || c != ' ' || x != start_x) + + // haleyjd 20110213: found MORE code ignored/misinterpreted by Hex-Rays: + // Underscores are replaced by spaces. + if(c == '_') + c = ' '; + else if (c == ' ' && x == start_x) // skip spaces at the start of a line + continue; + + c = toupper(c) - HU_FONTSTART; + + if(c >= 0 && c < HU_FONTSIZE) { - c = toupper(c) - HU_FONTSTART; + patch_t *patch = yfont[(int) c]; + int width = SHORT(patch->width); - if(c >= 0 && c < HU_FONTSIZE) + if(x + width <= (SCREENWIDTH - 20)) { - patch_t *patch = yfont[(int) c]; - int width = SHORT(patch->width); - - if(x + width <= (SCREENWIDTH - 20)) - { - // haleyjd: STRIFE-TODO: bit different than the exe... for now - if(!D_PatchClipCallback(patch, x + SHORT(patch->leftoffset), - y + SHORT(patch->topoffset))) - return; - V_DrawPatchDirect(x, y, patch); - x = x + width; - } - else - { - x = start_x; - --rover; - y += 12; - } + // haleyjd: STRIFE-TODO: bit different than the exe... for now + if(!D_PatchClipCallback(patch, x + SHORT(patch->leftoffset), + y + SHORT(patch->topoffset))) + return; + V_DrawPatchDirect(x, y, patch); + x = x + width; } else { - x += 4; + x = start_x; + --rover; + y += 12; } } + else + { + x += 4; + } } } diff --git a/src/strife/st_stuff.c b/src/strife/st_stuff.c index 772050d6..934ce42c 100644 --- a/src/strife/st_stuff.c +++ b/src/strife/st_stuff.c @@ -76,7 +76,6 @@ // STATUS BAR DATA // - // Palette indices. // For damage/bonus red-/gold-shifts #define STARTREDPALS 1 @@ -109,35 +108,12 @@ #define ST_HEALTHX 79 #define ST_HEALTHY 162 -// 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 +// [STRIFE] +// Removed: +// * Weapon pos. +// * Frags pos. +// * ARMOR number pos. +// * Key icon positions. // Ammunition counter. // haleyjd 20110213 [STRIFE]: ammo counters for the popup widget @@ -148,42 +124,15 @@ static const int st_wforammo[NUMAMMO] = { 3, 3, 2, 3, 3, 2, 3 }; // Indicate maximum ammunition. // Only needed because backpack exists. // haleyjd 20110213 [STRIFE]: maxammo counters for the popup widget -#define ST_POPUPMAXAMMOX 239 - -// 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 +#define ST_POPUPMAXAMMOX 239 - // 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 +// [STRIFE] +// Removed: +// * Doom weapon stuff +// * DETH title (???) // Dimensions given in characters. -#define ST_MSGWIDTH 52 +#define ST_MSGWIDTH 52 // haleyjd 08/31/10: [STRIFE] // * Removed faces. @@ -332,7 +281,7 @@ void M_SizeDisplay(int choice); // villsa [STRIFE] void ST_Stop(void); // [STRIFE] -static char st_msgbuf[52]; +static char st_msgbuf[ST_MSGWIDTH]; // Respond to keyboard input events, // intercept cheats. @@ -1212,6 +1161,105 @@ static void ST_drawTime(int x, int y, int time) HUlib_drawYellowText(x, y, string); } +#define ST_KEYSPERPAGE 10 +#define ST_KEYS_X 20 +#define ST_KEYS_Y 63 +#define ST_KEYNAME_X 17 +#define ST_KEYNAME_Y 4 +#define ST_KEYS_YSTEP 17 +#define ST_KEYS_NUMROWS 4 +#define ST_KEYS_COL2X 160 + +// +// ST_drawKeysPopup +// +// haleyjd 20110213: [STRIFE] New function +// This has taken the longest out of almost everything to get working properly. +// +static boolean ST_drawKeysPopup(void) +{ + int x, y, key, keycount; + mobjinfo_t *info; + + V_DrawXlaPatch(0, 56, invpbak2); + V_DrawPatchDirect(0, 56, invpop2); + + if(deathmatch) + { + // STRIFE-TODO: In deathmatch, the keys popup is replaced by a chart + // of frag counts + } + else + { + // Bounds-check page number + if(st_keypage < 0 || st_keypage > 2) + { + st_keypage = -1; + st_popupdisplaytics = 0; + st_displaypopup = false; + + return false; + } + + // Are there any keys to display on this page? + if(st_keypage > 0) + { + boolean haskeyinrange = false; + + for(key = ST_KEYSPERPAGE * st_keypage, keycount = 0; + keycount < ST_KEYSPERPAGE && key < NUMCARDS; + ++key, ++keycount) + { + if(plyr->cards[key]) + haskeyinrange = true; + } + + if(!haskeyinrange) + { + st_displaypopup = false; + st_showkeys = false; + st_keypage = -1; + + return false; + } + } + + // Draw the keys for the current page + key = ST_KEYSPERPAGE * st_keypage; + keycount = 0; + x = ST_KEYS_X; + y = ST_KEYS_Y; + info = &mobjinfo[MT_KEY_BASE + key]; + + for(; keycount < ST_KEYSPERPAGE && key < NUMCARDS; ++key, ++keycount, ++info) + { + char sprname[8]; + patch_t *patch; + memset(sprname, 0, sizeof(sprname)); + + if(plyr->cards[key]) + { + // Get spawnstate sprite name and load corresponding icon + DEH_snprintf(sprname, sizeof(sprname), "I_%s", + sprnames[states[info->spawnstate].sprite]); + patch = W_CacheLumpName(sprname, PU_CACHE); + V_DrawPatchDirect(x, y, patch); + HUlib_drawYellowText(x + ST_KEYNAME_X, y + ST_KEYNAME_Y, info->name); + } + + if(keycount != ST_KEYS_NUMROWS) + y += ST_KEYS_YSTEP; + else + { + x = ST_KEYS_COL2X; + y = ST_KEYS_Y; + } + } + } + + return true; +} + // // ST_DrawExternal // @@ -1254,10 +1302,9 @@ boolean ST_DrawExternal(void) { int keys = 0; - // villsa [STRIFE] TODO + // villsa [STRIFE] keys popup if(st_showkeys || st_popupdisplaytics) - return true; // temp - //return ST_drawKeysPopup(); + return ST_drawKeysPopup(); V_DrawXlaPatch(0, 56, invpbak); V_DrawPatchDirect(0, 56, invpop); diff --git a/src/v_video.c b/src/v_video.c index 3d874d6c..d18dbb7a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -653,7 +653,7 @@ void WritePCXfile(char *filename, byte *data, void V_ScreenShot(char *format) { int i; - char lbmname[12]; + char lbmname[16]; // haleyjd 20110213: BUG FIX - 12 is too small! // find a file name to save it to |