- cleaned up the setup code and consolidated everything in a separate file.

This commit is contained in:
Christoph Oelckers 2020-07-15 21:11:23 +02:00
parent ea6c74d0e6
commit d139720607
9 changed files with 472 additions and 465 deletions

View file

@ -15,6 +15,7 @@ set( PCH_SOURCES
src/dispatch.cpp src/dispatch.cpp
src/flags_d.cpp src/flags_d.cpp
src/flags_r.cpp src/flags_r.cpp
src/game.cpp
src/game_misc.cpp src/game_misc.cpp
src/gamedef.cpp src/gamedef.cpp
src/gameexec.cpp src/gameexec.cpp

View file

@ -0,0 +1,466 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
Copyright (C) 2020 - Christoph Oelckers
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
Duke Nukem 3D 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.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
*/
//-------------------------------------------------------------------------
// all code related to startup, up to entering the main loop.
#include "ns.h" // Must come before everything else!
#include "duke3d.h"
#include "baselayer.h"
#include "m_argv.h"
#include "mapinfo.h"
#include "texturemanager.h"
#include "statusbar.h"
#include "st_start.h"
#include "i_interface.h"
#include "prediction.h"
#include "glbackend/glbackend.h"
BEGIN_DUKE_NS
void SetDispatcher();
void InitCheats();
int registerosdcommands(void);
//---------------------------------------------------------------------------
//
// game specific command line args go here.
//
//---------------------------------------------------------------------------
static void checkcommandline()
{
auto val = Args->CheckValue("-skill");
if (!val) val = Args->CheckValue("-s");
if (val)
{
ud.m_player_skill = ud.player_skill = clamp((int)strtol(val, nullptr, 0), 0, 5);
if (ud.m_player_skill == 4) ud.m_respawn_monsters = ud.respawn_monsters = 1;
}
val = Args->CheckValue("-respawn");
if (!val) val = Args->CheckValue("-t");
if (val)
{
if (*val == '1') ud.m_respawn_monsters = 1;
else if (*val == '2') ud.m_respawn_items = 1;
else if (*val == '3') ud.m_respawn_inventory = 1;
else
{
ud.m_respawn_monsters = 1;
ud.m_respawn_items = 1;
ud.m_respawn_inventory = 1;
}
Printf("Respawn on.\n");
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void genspriteremaps(void)
{
int j;
auto fr = fileSystem.OpenFileReader("lookup.dat");
if (!fr.isOpen())
return;
j = lookups.loadTable(fr);
if (j < 0)
{
if (j == -1)
Printf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
return;
}
uint8_t paldata[768];
for (j=1; j<=5; j++)
{
if (fr.Read(paldata, 768) != 768)
return;
for (int k = 0; k < 768; k++) // Build uses 6 bit VGA palettes.
paldata[k] = (paldata[k] << 2) | (paldata[k] >> 6);
paletteSetColorTable(j, paldata, j == DREALMSPAL || j == ENDINGPAL, j < DREALMSPAL);
}
for (int i = 0; i < 256; i++)
{
// swap red and blue channels.
paldata[i * 3] = GPalette.BaseColors[i].b;
paldata[i * 3+1] = GPalette.BaseColors[i].g;
paldata[i * 3+2] = GPalette.BaseColors[i].r;
}
paletteSetColorTable(DRUGPAL, paldata, false, false); // todo: implement this as a shader effect (swap R and B in postprocessing.)
if (isRR())
{
uint8_t table[256];
for (j = 0; j < 256; j++)
table[j] = j;
for (j = 0; j < 32; j++)
table[j] = j + 32;
lookups.makeTable(7, table, 0, 0, 0, 0);
for (j = 0; j < 256; j++)
table[j] = j;
lookups.makeTable(30, table, 0, 0, 0, 0);
lookups.makeTable(31, table, 0, 0, 0, 0);
lookups.makeTable(32, table, 0, 0, 0, 0);
lookups.makeTable(33, table, 0, 0, 0, 0);
if (isRRRA())
lookups.makeTable(105, table, 0, 0, 0, 0);
int unk = 63;
for (j = 64; j < 80; j++)
{
unk--;
table[j] = unk;
table[j + 16] = j - 24;
}
table[80] = 80;
table[81] = 81;
for (j = 0; j < 32; j++)
{
table[j] = j + 32;
}
lookups.makeTable(34, table, 0, 0, 0, 0);
for (j = 0; j < 256; j++)
table[j] = j;
for (j = 0; j < 16; j++)
table[j] = j + 129;
for (j = 16; j < 32; j++)
table[j] = j + 192;
lookups.makeTable(35, table, 0, 0, 0, 0);
if (isRRRA())
{
lookups.makeTable(50, nullptr, 12 * 4, 12 * 4, 12 * 4, 0);
lookups.makeTable(51, nullptr, 12 * 4, 12 * 4, 12 * 4, 0);
lookups.makeTable(54, lookups.getTable(8), 32 * 4, 32 * 4, 32 * 4, 0);
}
}
}
//---------------------------------------------------------------------------
//
// Define sky layouts.
// This one's easy - the other games are a total mess
//
//---------------------------------------------------------------------------
static void setupbackdrop()
{
static const uint16_t pskyoff[8] = {};
static const uint16_t moonoff[8] = { 0, 2, 3, 0, 2, 0, 1, 0 };
static const uint16_t orbitoff[8] = { 0, 0, 4, 0, 0, 1, 2, 3 };
static const uint16_t laoff[8] = { 1, 2, 1, 3, 4, 0, 2, 3 };
static const uint16_t defoff[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
static const uint16_t defoff1[8] = { 1, 2, 3, 4, 5, 6, 7, 0 };
static const uint16_t defoff4[8] = { 4, 5, 6, 7, 0, 1, 2, 3 };
static const uint16_t defoff7[8] = { 7, 0, 1, 2, 3, 4, 5, 6 };
defineSky(DEFAULTPSKY, 32768, 3, pskyoff);
defineSky(TILE_CLOUDYOCEAN, 65536, 3, pskyoff);
defineSky(TILE_MOONSKY1, 32768, 3, moonoff);
defineSky(TILE_BIGORBIT1, 32768, 3, orbitoff);
defineSky(TILE_LA, 16384 + 1024, 3, laoff);
if (isWorldTour())
{
defineSky(5284, 65536, 3, defoff);
defineSky(5412, 65536, 3, defoff, 48);
defineSky(5420, 65536, 3, defoff, 48);
defineSky(5450, 65536, 3, defoff7, 48);
defineSky(5548, 65536, 3, defoff, 48);
defineSky(5556, 65536, 3, defoff1, 48);
defineSky(5720, 65536, 3, defoff4, 48);
defineSky(5814, 65536, 3, defoff, 48);
}
// Ugh... Since we do not know up front which of these tiles are skies we have to set them all...
if (isRRRA())
{
for (int i = 0; i < MAXUSERTILES; i++)
{
if (tilesiz[i].x == 512)
{
defineSky(i, 32768, 1, pskyoff);
}
else if (tilesiz[i].x == 1024)
{
defineSky(i, 32768, 0, pskyoff);
}
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void SetupGameButtons()
{
static const char* actions[] = {
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"Weapon_1",
"Weapon_2",
"Weapon_3",
"Weapon_4",
"Weapon_5",
"Weapon_6",
"Weapon_7",
"Weapon_8",
"Weapon_9",
"Weapon_10",
"Inventory",
"Inventory_Left",
"Inventory_Right",
"Holo_Duke", // Duke3D", isRR()
"Jetpack",
"NightVision",
"MedKit",
"TurnAround",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Center_View",
"Holster_Weapon",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Toggle_Crosshair",
"Steroids",
"Quick_Kick",
"Next_Weapon",
"Previous_Weapon",
"Dpad_Select",
"Dpad_Aiming",
"Last_Weapon",
"Alt_Weapon",
"Third_Person_View",
"Show_DukeMatch_Scores",
"Toggle_Crouch", // This is the last one used by EDuke32.
};
buttonMap.SetButtons(actions, NUM_ACTIONS);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void ticker(void)
{
S_Update();
// we need CONTROL_GetInput in order to pick up joystick button presses
if (!(ps[myconnectindex].gm & MODE_GAME))
{
ControlInfo noshareinfo;
CONTROL_GetInput(&noshareinfo);
C_RunDelayedCommands();
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void loaddefs()
{
const char *defsfile = G_DefFile();
cycle_t deftimer;
deftimer.Reset();
deftimer.Clock();
if (!loaddefinitionsfile(defsfile))
{
deftimer.Unclock();
Printf("Definitions file \"%s\" loaded in %.3f ms.\n", defsfile, deftimer.TimeMS());
}
userConfig.AddDefs.reset();
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void initTiles()
{
if (TileFiles.artLoadFiles("tiles%03i.art") < 0)
I_FatalError("Failed loading art.");
tileDelete(TILE_MIRROR);
skiptile = TILE_W_FORCEFIELD + 1;
if (isRR())
tileDelete(0);
tileDelete(FOF);
}
//---------------------------------------------------------------------------
//
// set up the game module's state
//
//---------------------------------------------------------------------------
static void Startup(void)
{
ud.god = 0;
ud.m_respawn_items = 0;
ud.m_respawn_monsters = 0;
ud.m_respawn_inventory = 0;
ud.cashman = 0;
ud.m_player_skill = ud.player_skill = 2;
ud.wchoice[0][0] = 3;
ud.wchoice[0][1] = 4;
ud.wchoice[0][2] = 5;
ud.wchoice[0][3] = 7;
ud.wchoice[0][4] = 8;
ud.wchoice[0][5] = 6;
ud.wchoice[0][6] = 0;
ud.wchoice[0][7] = 2;
ud.wchoice[0][8] = 9;
ud.wchoice[0][9] = 1;
ud.multimode = 1;
ud.m_monsters_off = userConfig.nomonsters;
ps[0].aim_mode = 1;
ud.camerasprite = -1;
if (fileSystem.FileExists("DUKESW.BIN"))
g_Shareware = 1;
numplayers = 1;
playerswhenstarted = ud.multimode;
connectpoint2[0] = -1;
SetDispatcher();
S_InitSound();
timerInit(TICRATE);
timerSetCallback(ticker);
loadcons();
fi.initactorflags();
OnEvent(EVENT_INIT);
enginecompatibility_mode = ENGINECOMPATIBILITY_19961112;
if (engineInit())
G_FatalEngineError();
setupbackdrop();
//Net_SendClientInfo();
initTiles();
fi.InitFonts();
genspriteremaps();
TileFiles.PostLoadSetup();
SetupGameButtons();
InitCheats();
checkcommandline();
registerosdcommands();
screenpeek = myconnectindex;
ps[myconnectindex].palette = BASEPAL;
for (int j=numplayers; j<ud.multimode; j++)
{
mysnprintf(ud.user_name[j], sizeof(ud.user_name[j]),"%s %d", GStrings("PLAYER"),j+1);
ps[j].weaponswitch = 3;
ps[j].auto_aim = 0;
}
loaddefs();
if (ud.multimode > 1)
{
ud.m_monsters_off = 1;
ud.m_player_skill = 0;
}
ud.last_level = -1;
hud_size.Callback();
hud_scale.Callback();
}
//---------------------------------------------------------------------------
//
// main entry point, sets up the game module and the engine, then enters the main loop
//
//---------------------------------------------------------------------------
void app_loop();
int GameInterface::app_main()
{
Startup();
enginePostInit();
videoInit();
videoSetPalette(BASEPAL);
app_loop();
return 0;
}
END_DUKE_NS

View file

@ -68,13 +68,6 @@ struct TileInfo
extern TileInfo tileinfo[MAXTILES]; extern TileInfo tileinfo[MAXTILES];
extern void setupbackdrop();
//////////
extern void genspriteremaps(void);
extern int32_t actor_tog; extern int32_t actor_tog;
extern int32_t otherp; extern int32_t otherp;

View file

@ -104,38 +104,6 @@ void setmapfog(int fogtype)
GLInterface.SetMapFog(fogtype != 0); GLInterface.SetMapFog(fogtype != 0);
} }
//---------------------------------------------------------------------------
//
// game specific command line args go here.
//
//---------------------------------------------------------------------------
void checkcommandline()
{
auto val = Args->CheckValue("-skill");
if (!val) val = Args->CheckValue("-s");
if (val)
{
ud.m_player_skill = ud.player_skill = clamp((int)strtol(val, nullptr, 0), 0, 5);
if (ud.m_player_skill == 4) ud.m_respawn_monsters = ud.respawn_monsters = 1;
}
val = Args->CheckValue("-respawn");
if (!val) val = Args->CheckValue("-t");
if (val)
{
if (*val == '1') ud.m_respawn_monsters = 1;
else if (*val == '2') ud.m_respawn_items = 1;
else if (*val == '3') ud.m_respawn_inventory = 1;
else
{
ud.m_respawn_monsters = 1;
ud.m_respawn_items = 1;
ud.m_respawn_inventory = 1;
}
Printf("Respawn on.\n");
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// fixme: Menu does not call this // fixme: Menu does not call this
@ -158,101 +126,6 @@ void gameexitfrommenu()
ST_Endoom(); ST_Endoom();
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void genspriteremaps(void)
{
int j;
auto fr = fileSystem.OpenFileReader("lookup.dat");
if (!fr.isOpen())
return;
j = lookups.loadTable(fr);
if (j < 0)
{
if (j == -1)
Printf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
return;
}
uint8_t paldata[768];
for (j=1; j<=5; j++)
{
if (fr.Read(paldata, 768) != 768)
return;
for (int k = 0; k < 768; k++) // Build uses 6 bit VGA palettes.
paldata[k] = (paldata[k] << 2) | (paldata[k] >> 6);
paletteSetColorTable(j, paldata, j == DREALMSPAL || j == ENDINGPAL, j < DREALMSPAL);
}
for (int i = 0; i < 256; i++)
{
// swap red and blue channels.
paldata[i * 3] = GPalette.BaseColors[i].b;
paldata[i * 3+1] = GPalette.BaseColors[i].g;
paldata[i * 3+2] = GPalette.BaseColors[i].r;
}
paletteSetColorTable(DRUGPAL, paldata, false, false); // todo: implement this as a shader effect (swap R and B in postprocessing.)
if (isRR())
{
uint8_t table[256];
for (j = 0; j < 256; j++)
table[j] = j;
for (j = 0; j < 32; j++)
table[j] = j + 32;
lookups.makeTable(7, table, 0, 0, 0, 0);
for (j = 0; j < 256; j++)
table[j] = j;
lookups.makeTable(30, table, 0, 0, 0, 0);
lookups.makeTable(31, table, 0, 0, 0, 0);
lookups.makeTable(32, table, 0, 0, 0, 0);
lookups.makeTable(33, table, 0, 0, 0, 0);
if (isRRRA())
lookups.makeTable(105, table, 0, 0, 0, 0);
int unk = 63;
for (j = 64; j < 80; j++)
{
unk--;
table[j] = unk;
table[j + 16] = j - 24;
}
table[80] = 80;
table[81] = 81;
for (j = 0; j < 32; j++)
{
table[j] = j + 32;
}
lookups.makeTable(34, table, 0, 0, 0, 0);
for (j = 0; j < 256; j++)
table[j] = j;
for (j = 0; j < 16; j++)
table[j] = j + 129;
for (j = 16; j < 32; j++)
table[j] = j + 192;
lookups.makeTable(35, table, 0, 0, 0, 0);
if (isRRRA())
{
lookups.makeTable(50, nullptr, 12 * 4, 12 * 4, 12 * 4, 0);
lookups.makeTable(51, nullptr, 12 * 4, 12 * 4, 12 * 4, 0);
lookups.makeTable(54, lookups.getTable(8), 32 * 4, 32 * 4, 32 * 4, 0);
}
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// This now redirects the messagew to the console's notification display // This now redirects the messagew to the console's notification display
@ -863,58 +736,6 @@ int startrts(int lumpNum, int localPlayer)
} }
//---------------------------------------------------------------------------
//
// Define sky layouts.
// This one's easy - the other games are a total mess
//
//---------------------------------------------------------------------------
void setupbackdrop()
{
static const uint16_t pskyoff[8] = {};
static const uint16_t moonoff[8] = { 0, 2, 3, 0, 2, 0, 1, 0 };
static const uint16_t orbitoff[8] = { 0, 0, 4, 0, 0, 1, 2, 3 };
static const uint16_t laoff[8] = { 1, 2, 1, 3, 4, 0, 2, 3 };
static const uint16_t defoff[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
static const uint16_t defoff1[8] = { 1, 2, 3, 4, 5, 6, 7, 0 };
static const uint16_t defoff4[8] = { 4, 5, 6, 7, 0, 1, 2, 3 };
static const uint16_t defoff7[8] = { 7, 0, 1, 2, 3, 4, 5, 6 };
defineSky(DEFAULTPSKY, 32768, 3, pskyoff);
defineSky(TILE_CLOUDYOCEAN, 65536, 3, pskyoff);
defineSky(TILE_MOONSKY1, 32768, 3, moonoff);
defineSky(TILE_BIGORBIT1, 32768, 3, orbitoff);
defineSky(TILE_LA, 16384 + 1024, 3, laoff);
if (isWorldTour())
{
defineSky(5284, 65536, 3, defoff);
defineSky(5412, 65536, 3, defoff, 48);
defineSky(5420, 65536, 3, defoff, 48);
defineSky(5450, 65536, 3, defoff7, 48);
defineSky(5548, 65536, 3, defoff, 48);
defineSky(5556, 65536, 3, defoff1, 48);
defineSky(5720, 65536, 3, defoff4, 48);
defineSky(5814, 65536, 3, defoff, 48);
}
// Ugh... Since we do not know up front which of these tiles are skies we have to set them all...
if (isRRRA())
{
for (int i = 0; i < MAXUSERTILES; i++)
{
if (tilesiz[i].x == 512)
{
defineSky(i, 32768, 1, pskyoff);
}
else if (tilesiz[i].x == 1024)
{
defineSky(i, 32768, 0, pskyoff);
}
}
}
}
bool GameInterface::automapActive() bool GameInterface::automapActive()
{ {
return ud.overhead_on != 0; return ud.overhead_on != 0;

View file

@ -86,7 +86,6 @@ enum
}; };
G_EXTERN char g_loadFromGroupOnly; G_EXTERN char g_loadFromGroupOnly;
G_EXTERN char g_skillCnt;
G_EXTERN char pus,pub; G_EXTERN char pus,pub;
G_EXTERN char ready2send; G_EXTERN char ready2send;
#define MAXPLAYERNAME 32 #define MAXPLAYERNAME 32
@ -103,7 +102,7 @@ G_EXTERN int32_t movefifosendplc;
G_EXTERN int32_t predictfifoplc; G_EXTERN int32_t predictfifoplc;
G_EXTERN int32_t g_networkBroadcastMode, g_movesPerPacket; G_EXTERN int32_t g_networkBroadcastMode;
G_EXTERN int32_t g_animWallCnt; G_EXTERN int32_t g_animWallCnt;
#define numanimwalls g_animWallCnt #define numanimwalls g_animWallCnt
@ -211,7 +210,7 @@ G_EXTERN int16_t fakebubba_spawn, mamaspawn_count, banjosound, g_bellTime, BellS
#define word_119BE0 BellSprite #define word_119BE0 BellSprite
G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS]; // move these back into the base structs! G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS]; // move these back into the base structs!
G_EXTERN uint8_t enemysizecheat, ufospawnsminion, pistonsound, chickenphase, RRRA_ExitedLevel, fogactive; G_EXTERN uint8_t enemysizecheat, ufospawnsminion, pistonsound, chickenphase, RRRA_ExitedLevel, fogactive;
G_EXTERN int32_t g_cdTrack; extern int32_t g_cdTrack;
#define raat607 enemysizecheat // only as a reminder #define raat607 enemysizecheat // only as a reminder
#define raat605 chickenphase #define raat605 chickenphase
#define at59d yeehaa_timer #define at59d yeehaa_timer

View file

@ -50,8 +50,6 @@ BEGIN_DUKE_NS
void nonsharedkeys(void) void nonsharedkeys(void)
{ {
static int nonsharedtimer; static int nonsharedtimer;
short i, ch, weapon;
int j;
if (ud.recstat == 2) if (ud.recstat == 2)
{ {

View file

@ -54,12 +54,12 @@ struct user_defs
short last_level, secretlevel; short last_level, secretlevel;
int const_visibility; int const_visibility;
int camera_time, folfvel, folavel, folx, foly, fola; int folfvel, folavel, folx, foly, fola;
int reccnt; int reccnt;
int runkey_mode, statusbarscale, mouseaiming, weaponswitch; int runkey_mode, statusbarscale, mouseaiming, weaponswitch;
int entered_name, shadows, fta_on, executions, auto_run; int entered_name, shadows, executions, auto_run;
int coords, tickrate, levelstats, m_coop, coop, screen_size, lockout, crosshair; int coords, tickrate, levelstats, m_coop, coop, screen_size, lockout, crosshair;
int wchoice[MAXPLAYERS][MAX_WEAPONS], playerai; int wchoice[MAXPLAYERS][MAX_WEAPONS], playerai;

View file

@ -44,16 +44,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "st_start.h" #include "st_start.h"
#include "i_interface.h" #include "i_interface.h"
// Uncomment to prevent anything except mirrors from drawing. It is sensible to
// also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
//#define DEBUG_MIRRORS_ONLY
BEGIN_DUKE_NS BEGIN_DUKE_NS
void SetDispatcher();
void InitCheats();
void checkcommandline();
int registerosdcommands(void);
int32_t moveloop(void); int32_t moveloop(void);
int menuloop(void); int menuloop(void);
void advancequeue(int myconnectindex); void advancequeue(int myconnectindex);
@ -76,270 +68,6 @@ weaponhit hittype[MAXSPRITES];
ActorInfo actorinfo[MAXTILES]; ActorInfo actorinfo[MAXTILES];
player_struct ps[MAXPLAYERS]; player_struct ps[MAXPLAYERS];
static void gameTimerHandler(void)
{
S_Update();
// we need CONTROL_GetInput in order to pick up joystick button presses
if (!(ps[myconnectindex].gm & MODE_GAME))
{
ControlInfo noshareinfo;
CONTROL_GetInput(&noshareinfo);
C_RunDelayedCommands();
}
}
void G_InitTimer(int32_t ticspersec)
{
if (g_timerTicsPerSecond != ticspersec)
{
timerUninit();
timerInit(ticspersec);
g_timerTicsPerSecond = ticspersec;
}
}
static int parsedefinitions_game(scriptfile *, int);
/*
===================
=
= G_Startup
=
===================
*/
static void G_Startup(void)
{
timerInit(TICRATE);
timerSetCallback(gameTimerHandler);
loadcons();
fi.initactorflags();
if (IsGameEvent(EVENT_INIT))
{
SetGameVarID(g_iReturnVarID, -1, -1, -1);
OnEvent(EVENT_INIT);
}
enginecompatibility_mode = ENGINECOMPATIBILITY_19961112;
if (engineInit())
G_FatalEngineError();
// These depend on having the dynamic tile and/or sound mappings set up:
setupbackdrop();
//Net_SendClientInfo();
if (userConfig.CommandMap.IsNotEmpty())
{
if (VOLUMEONE)
{
Printf("The -map option is available in the registered version only!\n");
userConfig.CommandMap = "";
}
}
if (numplayers > 1)
Printf("Multiplayer initialized.\n");
if (TileFiles.artLoadFiles("tiles%03i.art") < 0)
I_FatalError("Failed loading art.");
fi.InitFonts();
// Make the fullscreen nuke logo background non-fullbright. Has to be
// after dynamic tile remapping (from C_Compile) and loading tiles.
picanm[TILE_LOADSCREEN].sf |= PICANM_NOFULLBRIGHT_BIT;
// Printf("Loading palette/lookups...\n");
genspriteremaps();
TileFiles.PostLoadSetup();
screenpeek = myconnectindex;
}
void app_loop();
// TODO: reorder (net)weaponhit to eliminate slop and update assertion
EDUKE32_STATIC_ASSERT(sizeof(weaponhit)%4 == 0);
static const char* actions[] = {
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"Weapon_1",
"Weapon_2",
"Weapon_3",
"Weapon_4",
"Weapon_5",
"Weapon_6",
"Weapon_7",
"Weapon_8",
"Weapon_9",
"Weapon_10",
"Inventory",
"Inventory_Left",
"Inventory_Right",
"Holo_Duke", // Duke3D", isRR()
"Jetpack",
"NightVision",
"MedKit",
"TurnAround",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Center_View",
"Holster_Weapon",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Toggle_Crosshair",
"Steroids",
"Quick_Kick",
"Next_Weapon",
"Previous_Weapon",
"Dpad_Select",
"Dpad_Aiming",
"Last_Weapon",
"Alt_Weapon",
"Third_Person_View",
"Show_DukeMatch_Scores",
"Toggle_Crouch", // This is the last one used by EDuke32.
};
int GameInterface::app_main()
{
for (int i = 0; i < MAXPLAYERS; i++)
{
for (int j = 0; j < 10; j++)
{
const char* s = "3457860291";
ud.wchoice[i][j] = s[j] - '0';
}
}
SetDispatcher();
buttonMap.SetButtons(actions, NUM_ACTIONS);
g_skillCnt = 4;
ud.multimode = 1;
ud.m_monsters_off = userConfig.nomonsters;
g_movesPerPacket = 1;
//bufferjitter = 1;
//initsynccrc();
checkcommandline();
ps[0].aim_mode = 1;
ud.camerasprite = -1;
ud.camera_time = 0;//4;
S_InitSound();
if (isRR())
{
g_cdTrack = -1;
}
InitCheats();
if (VOLUMEONE)
g_Shareware = 1;
else
{
if (fileSystem.FileExists("DUKESW.BIN")) // JBF 20030810
{
g_Shareware = 1;
}
}
numplayers = 1;
playerswhenstarted = ud.multimode;
connectpoint2[0] = -1;
G_Startup(); // a bunch of stuff including compiling cons
ps[myconnectindex].palette = BASEPAL;
for (int i=1, j=numplayers; j<ud.multimode; j++)
{
Bsprintf(ud.user_name[j],"%s %d", GStrings("PLAYER"),j+1);
ps[j].weaponswitch = 3;
ps[j].auto_aim = 0;
i = 1-i;
}
const char *defsfile = G_DefFile();
uint32_t stime = timerGetTicks();
if (!loaddefinitionsfile(defsfile))
{
uint32_t etime = timerGetTicks();
Printf("Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime-stime);
}
userConfig.AddDefs.reset();
enginePostInit();
hud_size.Callback();
hud_scale.Callback();
tileDelete(TILE_MIRROR);
skiptile = TILE_W_FORCEFIELD + 1;
if (isRR())
tileDelete(0);
tileDelete(13);
// getnames();
if (ud.multimode > 1)
{
ud.m_monsters_off = 1;
ud.m_player_skill = 0;
}
playerswhenstarted = ud.multimode; // XXX: redundant?
ud.last_level = -1;
registerosdcommands();
videoInit();
V_LoadTranslations();
videoSetPalette(BASEPAL);
FX_StopAllSounds();
app_loop();
return 0;
}
void app_loop() void app_loop()
{ {

View file

@ -52,6 +52,7 @@ int32_t g_shrinkerRadius = 650;
int32_t g_spriteGravity = 176; int32_t g_spriteGravity = 176;
int32_t g_timerTicsPerSecond = TICRATE; int32_t g_timerTicsPerSecond = TICRATE;
int32_t g_tripbombRadius = 3880; int32_t g_tripbombRadius = 3880;
int32_t g_cdTrack = -1;
uint16_t frags[MAXPLAYERS][MAXPLAYERS]; uint16_t frags[MAXPLAYERS][MAXPLAYERS];
input_t sync[MAXPLAYERS]; input_t sync[MAXPLAYERS];