From 0e051a9d96b4b9d31b934f69882b25306d65c2cf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 29 Oct 2020 21:24:02 +0100 Subject: [PATCH] - precaching for WH. --- source/games/whaven/CMakeLists.txt | 1 + source/games/whaven/src/precache.cpp | 115 +++++++++++++++++++++++++++ source/games/whaven/src/wh.h | 1 + 3 files changed, 117 insertions(+) create mode 100644 source/games/whaven/src/precache.cpp diff --git a/source/games/whaven/CMakeLists.txt b/source/games/whaven/CMakeLists.txt index 436bc8ac9..350f6548c 100644 --- a/source/games/whaven/CMakeLists.txt +++ b/source/games/whaven/CMakeLists.txt @@ -46,6 +46,7 @@ set( PCH_SOURCES src/sound.cpp src/fonts.cpp src/screenflash.cpp + src/precache.cpp ) add_game_library2( whaven ) diff --git a/source/games/whaven/src/precache.cpp b/source/games/whaven/src/precache.cpp new file mode 100644 index 000000000..189f5c802 --- /dev/null +++ b/source/games/whaven/src/precache.cpp @@ -0,0 +1,115 @@ +#include "ns.h" +#include "wh.h" + +BEGIN_WH_NS + +void addTile(int num) +{ + markTileForPrecache(num, 0); +} + +void cachespritenum(int i) +{ + int maxc = 1; + if (sprite[i].picnum == RAT || sprite[i].picnum == GUARDIAN) + maxc = 15; + if (sprite[i].picnum == HANGMAN) + maxc = 40; + + if (sprite[i].picnum == GRONHAL || sprite[i].picnum == GRONMU || sprite[i].picnum == GRONSW) + maxc = 19; + + switch (sprite[i].picnum) + { + case GOBLINSTAND: + case GOBLIN: + maxc = 21; + break; + case KOBOLD: + maxc = 24; + break; + case DEVILSTAND: + case DEVIL: + maxc = 25; + break; + case DRAGON: + maxc = 11; + break; + + case SPIDER: + maxc = 39; + break; + case MINOTAUR: + maxc = 35; + break; + case FATWITCH: + maxc = 19; + break; + case SKULLY: + maxc = 20; + break; + case JUDYSIT: + case JUDY: + maxc = 18; + break; + } + for (int j = sprite[i].picnum; j < (sprite[i].picnum + maxc); j++) + addTile(j); +} + +void precacheTiles() +{ + for (int i = 0; i < numsectors; i++) { + addTile(sector[i].floorpicnum); + addTile(sector[i].ceilingpicnum); + } + for (int i = 0; i < numwalls; i++) { + addTile(wall[i].picnum); + if (wall[i].overpicnum >= 0) { + addTile(wall[i].overpicnum); + } + } + for (int i = 0; i < MAXSPRITES; i++) { + if (sprite[i].statnum < MAXSTATUS) + cachespritenum(i); + } + + addTile(BAT); + addTile(GOBLINATTACK); + addTile(MINOTAURATTACK); + addTile(KOBOLDATTACK); + addTile(FREDATTACK); + addTile(DEVILATTACK); + + for(int i = KNIFEREADY; i <= BIGAXEDRAW10; i++) //hud weapons + addTile(i); + for(int i = THEFONT; i < CRYSTALSTAFF; i++) //small font + addTile(i); + + addTile(SSTATUSBAR); + for(int i = 0; i < 8; i++) + addTile(sspellbookanim[i][0].daweaponframe); + + addTile(ANNIHILATE); + addTile(HELMET); + addTile(SSCOREBACKPIC); + addTile(SHEALTHBACK); + + for(int i = 0; i < 4; i++) { + addTile(SKEYBLANK+i); + addTile(SCARY+i); + } + + addTile(SPOTIONBACKPIC); + for(int i = 0; i < MAXPOTIONS; i++) { + addTile(SPOTIONARROW+i); + addTile(SFLASKBLUE+i); + } + addTile(SFLASKBLACK); + for(int i = 0; i < 5; i++) + addTile(spikeanimtics[i].daweaponframe); + + precacheMarkedTiles(); +} + +END_WH_NS diff --git a/source/games/whaven/src/wh.h b/source/games/whaven/src/wh.h index 0e12b2bd9..b8fb51202 100644 --- a/source/games/whaven/src/wh.h +++ b/source/games/whaven/src/wh.h @@ -498,6 +498,7 @@ inline int insertsprite(int sectnum, int statnum) } void analyzesprites(PLAYER& plr, int dasmoothratio); +void precacheTiles(); void startWh2Ending();