raze/source/games/duke/src/dispatch.cpp
Christoph Oelckers de92287d0b - fixed the messed up parameter order of OnEvent.
This should serve as a textbook example why passing around indices is a very, very bad idea!
2020-11-03 19:21:42 +01:00

280 lines
7 KiB
C++

//-------------------------------------------------------------------------
/*
Copyright (C) 2020 - Christoph Oelckers
This 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "global.h"
#include "dukeactor.h"
BEGIN_DUKE_NS
//---------------------------------------------------------------------------
//
// Dispatcher for functions where different variants exist for the two families of games.
//
//---------------------------------------------------------------------------
void initactorflags_d();
void initactorflags_r();
bool isadoorwall_d(int dapic);
bool isadoorwall_r(int dapic);
void animatewalls_d(void);
void animatewalls_r(void);
void operaterespawns_d(int low);
void operaterespawns_r(int low);
void operateforcefields_r(int s, int low);
void operateforcefields_d(int s, int low);
bool checkhitswitch_d(int snum, int w, int switchtype);
bool checkhitswitch_r(int snum, int w, int switchtype);
void activatebysector_d(int sect, int j);
void activatebysector_r(int sect, int j);
void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith);
void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith);
void checkplayerhurt_d(struct player_struct* p, int j);
void checkplayerhurt_r(struct player_struct* p, int j);
bool checkhitceiling_d(int sn);
bool checkhitceiling_r(int sn);
void checkhitsprite_d(int i, int sn);
void checkhitsprite_r(int i, int sn);
void checksectors_d(int snum);
void checksectors_r(int snum);
bool ceilingspace_d(int sectnum);
bool ceilingspace_r(int sectnum);
bool floorspace_d(int sectnum);
bool floorspace_r(int sectnum);
void addweapon_d(struct player_struct* p, int weapon);
void addweapon_r(struct player_struct* p, int weapon);
void hitradius_d(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
void hitradius_r(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
void lotsofmoney_d(DDukeActor* s, short n);
void lotsofmail_d(DDukeActor* s, short n);
void lotsofpaper_d(DDukeActor* s, short n);
void lotsoffeathers_r(DDukeActor* s, short n);
void guts_d(DDukeActor* s, short gtype, short n, short p);
void guts_r(DDukeActor* s, short gtype, short n, short p);
DDukeActor* ifhitsectors_d(int sectnum);
DDukeActor* ifhitsectors_r(int sectnum);
int ifhitbyweapon_r(DDukeActor* sn);
int ifhitbyweapon_d(DDukeActor* sn);
void fall_d(DDukeActor* i, int g_p);
void fall_r(DDukeActor* i, int g_p);
bool spawnweapondebris_d(int picnum, int dnum);
bool spawnweapondebris_r(int picnum, int dnum);
void respawnhitag_d(DDukeActor* g_sp);
void respawnhitag_r(DDukeActor* g_sp);
void checktimetosleep_d(DDukeActor* actor);
void checktimetosleep_r(DDukeActor* actor);
void move_d(DDukeActor* i, int g_p, int g_x);
void move_r(DDukeActor* i, int g_p, int g_x);
int spawn_d(int j, int pn);
int spawn_r(int j, int pn);
void incur_damage_d(struct player_struct* p);
void incur_damage_r(struct player_struct* p);
void shoot_d(int i, int atwith);
void shoot_r(int i, int atwith);
void selectweapon_d(int snum, int j);
void selectweapon_r(int snum, int j);
int doincrements_d(struct player_struct* p);
int doincrements_r(struct player_struct* p);
void checkweapons_d(struct player_struct* p);
void checkweapons_r(struct player_struct* p);
void processinput_d(int snum);
void processinput_r(int snum);
void displayweapon_d(int snum, double smoothratio);
void displayweapon_r(int snum, double smoothratio);
void displaymasks_d(int snum, double smoothratio);
void displaymasks_r(int snum, double smoothratio);
void think_d();
void think_r();
void animatesprites_d(int x, int y, int a, int smoothratio);
void animatesprites_r(int x, int y, int a, int smoothratio);
void Logo_d(const CompletionFunc&);
void Logo_r(const CompletionFunc&);
void InitFonts_d();
void InitFonts_r();
void PrintPaused_d();
void PrintPaused_r();
Dispatcher fi;
void SetDispatcher()
{
if (!isRR())
{
fi = {
Logo_d,
InitFonts_d,
PrintPaused_d,
think_d,
initactorflags_d,
isadoorwall_d,
animatewalls_d,
operaterespawns_d,
operateforcefields_d,
checkhitswitch_d,
activatebysector_d,
checkhitwall_d,
checkplayerhurt_d,
checkhitceiling_d,
checkhitsprite_d,
checksectors_d,
ceilingspace_d,
floorspace_d,
addweapon_d,
hitradius_d,
movesprite_d,
lotsofmoney_d,
lotsofmail_d,
lotsofpaper_d,
guts_d,
ifhitsectors_d,
ifhitbyweapon_d,
fall_d,
spawnweapondebris_d,
respawnhitag_d,
checktimetosleep_d,
move_d,
spawn_d,
incur_damage_d,
shoot_d,
selectweapon_d,
doincrements_d,
checkweapons_d,
processinput_d,
displayweapon_d,
displaymasks_d,
animatesprites_d,
};
}
else
{
fi = {
Logo_r,
InitFonts_r,
PrintPaused_r,
think_r,
initactorflags_r,
isadoorwall_r,
animatewalls_r,
operaterespawns_r,
operateforcefields_r,
checkhitswitch_r,
activatebysector_r,
checkhitwall_r,
checkplayerhurt_r,
checkhitceiling_r,
checkhitsprite_r,
checksectors_r,
ceilingspace_r,
floorspace_r,
addweapon_r,
hitradius_r,
movesprite_r,
lotsoffeathers_r,
lotsoffeathers_r,
lotsoffeathers_r,
guts_r,
ifhitsectors_r,
ifhitbyweapon_r,
fall_r,
spawnweapondebris_r,
respawnhitag_r,
checktimetosleep_r,
move_r,
spawn_r,
incur_damage_r,
shoot_r,
selectweapon_r,
doincrements_r,
checkweapons_r,
processinput_r,
displayweapon_r,
displaymasks_r,
animatesprites_r,
};
}
}
int TILE_BOX;
int TILE_TREE1;
int TILE_TREE2;
int TILE_TIRE;
int TILE_CONE;
int TILE_W_FORCEFIELD;
int TILE_CAMERA1;
int TILE_SCRAP6;
int TILE_APLAYER;
int TILE_DRONE;
int TILE_MENUSCREEN;
int TILE_SCREENBORDER;
int TILE_VIEWBORDER;
int TILE_LASERLINE;
int TILE_APLAYERTOP;
int TILE_CAMCORNER;
int TILE_CAMLIGHT;
int TILE_STATIC;
int TILE_BOTTOMSTATUSBAR;
int TILE_THREEDEE;
int TILE_INGAMEDUKETHREEDEE;
int TILE_PLUTOPAKSPRITE;
int TILE_MENUBAR;
int TILE_ATOMICHEALTH;
int TILE_FLOORSLIME;
int TILE_JIBS6;
int TILE_FIRE;
int TILE_WATERBUBBLE;
int TILE_SMALLSMOKE;
int TILE_BLOODPOOL;
int TILE_FOOTPRINTS;
int TILE_FOOTPRINTS2;
int TILE_FOOTPRINTS3;
int TILE_FOOTPRINTS4;
int TILE_CLOUDYSKIES;
int TILE_ARROW;
int TILE_ACCESSSWITCH;
int TILE_ACCESSSWITCH2;
int TILE_GLASSPIECES;
int TILE_HEN;
int TILE_BETAVERSION;
int TILE_MIRROR;
int TILE_CLOUDYOCEAN;
int TILE_MOONSKY1;
int TILE_BIGORBIT;
int TILE_LA;
int TILE_LOADSCREEN;
int TILE_CROSSHAIR;
int TILE_BIGORBIT1;
int TILE_HURTRAIL;
int TILE_FLOORPLASMA;
int TILE_EGG;
END_DUKE_NS