Initial game creation clean-up. Made race-selection in start menu work.

- NEEDS TESTING..
This commit is contained in:
ariclone 2000-07-23 19:10:30 +00:00
parent 9dca600b49
commit 520b965e9e
10 changed files with 244 additions and 357 deletions

View file

@ -21,6 +21,6 @@ include $(TOPDIR)/Rules.make
MODULE = game
OBJS = dummy.$(OE)
OBJS = game.$(OE)
include $(TOPDIR)/Common.mk

View file

@ -30,7 +30,7 @@ HDRS = actions.h ai.h ccl.h freecraft.h construct.h cursor.h font.h icons.h \
pud.h tileset.h unit.h unittype.h upgrade.h upgrade_structs.h \
ccl_sound.h sound.h sound_id.h unitsound.h wav.h sound_server.h \
video.h network.h goal.h ui.h button.h menus.h spells.h \
siod.h siodp.h iolib.h depend.h myendian.h rdtsc.h \
siod.h siodp.h iolib.h depend.h settings.h myendian.h rdtsc.h \
etlib/generic.h etlib/xmalloc.h etlib/hash.h etlib/dllist.h
all:

View file

@ -165,6 +165,8 @@ extern int FogOfWarBrightness;
extern int FogOfWarSaturation;
/// Forest regeneration
extern int ForestRegeneration;
/// Flag must reveal the map
extern int FlagRevealMap;
/*----------------------------------------------------------------------------
-- Functions

95
src/include/settings.h Normal file
View file

@ -0,0 +1,95 @@
// ___________ _________ _____ __
// \_ _____/______ ____ ____ \_ ___ \____________ _/ ____\/ |_
// | __) \_ __ \_/ __ \_/ __ \/ \ \/\_ __ \__ \\ __\\ __\
// | \ | | \/\ ___/\ ___/\ \____| | \// __ \| | | |
// \___ / |__| \___ >\___ >\______ /|__| (____ /__| |__|
// \/ \/ \/ \/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// FreeCraft - A free fantasy real time strategy game engine
//
/**@name settings.h - The game settings headerfile. */
//
// (c) Copyright 2000 by Andreas Arens
//
// $Id$
#ifndef __SETTINGS_H__
#define __SETTINGS_H__
//@{
/*----------------------------------------------------------------------------
-- Includes
----------------------------------------------------------------------------*/
#ifndef __STRUCT_SETTINGS__
#define __STRUCT_SETTINGS__
typedef struct _settings_ Settings;
#endif
#include "player.h"
/*----------------------------------------------------------------------------
-- Settings __WIP__
----------------------------------------------------------------------------*/
/**
** Settings structure
**
** This structure one day should contain all common game settings,
** in-game, or pre-start, and the individual (per player) presets.
** This allows central maintainance, easy (network-)negotiation,
** simplifies load/save/reinitialization, etc...
**
*/
struct _settings_ {
// Individual presets:
// For single-player game only Presets[0] will be used..
struct {
unsigned Race; /// race of the player
unsigned Team; /// team of player -- NOT SELECTABLE YET
} Presets[PlayerMax];
// Common settings:
unsigned Resources; /// preset resource factor
unsigned NumUnits; /// preset # of units
unsigned Opponents; /// preset # of ai-opponents
unsigned Terrain; /// terrain type (summer,winter,...)
};
#define SettingsPresetMapDefault (~0ul) /// Special: Use pud/cm supplied
/*
** Resource-Preset factor -- NOT USED YET
*/
#define SettingsResourcesMapDefault SettingsPresetMapDefault
#define SettingsResourcesLow 0
#define SettingsResourcesMedium 1
#define SettingsResourcesHigh 2
/*
** NumUnits start settings
*/
#define SettingsNumUnitsMapDefault SettingsPresetMapDefault
#define SettingsNumUnits1 0
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
extern Settings GameSettings; /// Game Settings
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
/// Create a game
extern void CreateGame(char* filename,WorldMap* map);
/// Init Setting to default values
extern void InitSettings(void);
//@}
#endif // !__SETTINGS_H__

View file

@ -24,6 +24,16 @@
-- Includes
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
extern global int ColorCycleAll;
#ifdef DEBUG
extern unsigned AllocatedGraphicMemory;
extern unsigned CompressedGraphicMemory;
#endif
/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/
@ -32,7 +42,6 @@ typedef unsigned char VMemType8; /// 8 bpp modes pointer
typedef unsigned short VMemType16; /// 16 bpp modes pointer
typedef struct { char a,b,c;} VMemType24;/// 24 bpp modes pointer
typedef unsigned long VMemType32; /// 32 bpp modes pointer
extern global int ColorCycleAll;
/**
** General video mode pointer.

View file

@ -45,113 +45,8 @@ global unsigned MapX; /// Map tile X start on display
global unsigned MapY; /// Map tile Y start on display
global unsigned MapWidth; /// map width in tiles
global unsigned MapHeight; /// map height in tiles
global int lcm_prevent_recurse = 0; /// prevent recursion through LoadGameMap
/*----------------------------------------------------------------------------
-- Map loading/saving
----------------------------------------------------------------------------*/
/**
** Load a clone map.
**
** @param filename map filename
** @param map map loaded
*/
local void LoadGameMap(const char* filename,WorldMap* map)
{
DebugLevel3(__FUNCTION__" %p \n",map);
#if defined(USE_CCL) || defined(USE_CCL2)
if (lcm_prevent_recurse) {
fprintf(stderr,"recursive use of load clone map!\n");
exit(-1);
}
lcm_prevent_recurse = 1;
gh_eval_file((char*)filename);
lcm_prevent_recurse = 0;
if (!ThisPlayer) { /// ARI: bomb if nothing was loaded!
fprintf(stderr,"%s: invalid clone map\n", filename);
exit(-1);
}
#else
fprintf(stderr,"Sorry, you need guile/siod installed to use clone maps!\n");
exit(-1);
#endif
}
/**
** Load any map.
**
** @param filename map filename
** @param map map loaded
*/
global void LoadMap(const char* filename,WorldMap* map)
{
const char* tmp;
tmp=strrchr(filename,'.');
if( tmp ) {
#ifdef USE_ZLIB
if( !strcmp(tmp,".gz") ) {
while( tmp-1>filename && *--tmp!='.' ) {
}
} else
#endif
#ifdef USE_BZ2LIB
if( !strcmp(tmp,".bz2") ) {
while( tmp-1>filename && *--tmp!='.' ) {
}
}
#endif
if( !strcmp(tmp,".cm")
#ifdef USE_ZLIB
|| !strcmp(tmp,".cm.gz")
#endif
#ifdef USE_BZ2LIB
|| !strcmp(tmp,".cm.bz2")
#endif
) {
LoadGameMap(filename,map);
return;
}
#if 0 // ARI: avoid delayed crash by not loading anything!
else if( !strcmp(tmp,".pud") || !strcmp(tmp,".pud.gz") || !strcmp(tmp,".pud.bz2") ) {
LoadPud(filename,map);
// return;
}
#endif
}
// ARI: This bombs out, if no pud, so will be safe.
LoadPud(filename,map);
}
/**
** Save a map.
**
** @param file Output file.
*/
global void SaveMap(FILE* file)
{
fprintf(file,"\n;;; -----------------------------------------\n");
fprintf(file,";;; MODULE: map $Id$\n");
fprintf(file,"(freecraft-map\n");
// FIXME: Need version number here!
fprintf(file," '(version %d.%d)\n",0,0);
fprintf(file," '(description \"Saved\")\n");
fprintf(file," '(terrain %d \"%s\")\n"
,TheMap.Terrain,Tilesets[TheMap.Terrain].Name);
fprintf(file," '(tiles #(\n");
fprintf(file," )\n");
fprintf(file,")\n");
fprintf(file,"(the-map\n");
fprintf(file," (%d %d)\n",TheMap.Width,TheMap.Height);
fprintf(file," %d\n",TheMap.NoFogOfWar);
fprintf(file,")\n");
}
global int FlagRevealMap; /// Flag must reveal the map
/*----------------------------------------------------------------------------
-- Visibile and explored handling

View file

@ -37,6 +37,7 @@
#include "unit.h"
#include "pud.h"
#include "iolib.h"
#include "settings.h"
#include "myendian.h"
@ -304,11 +305,11 @@ global PudInfo* GetPudInfo(const char* pud)
}
header[4]='\0';
if( !PudReadHeader(input,header,&length) ) {
fprintf(stderr,"%s: invalid pud\n", pud);
fprintf(stderr,"GetPudInfo: %s: invalid pud\n", pud);
exit(-1);
}
if( memcmp(header,"TYPE",4) || length!=16 ) {
fprintf(stderr,"%s: invalid pud\n", pud);
fprintf(stderr,"GetPudInfo: %s: invalid pud\n", pud);
exit(-1);
}
if( CLread(input,buf,16)!=16 ) { // IGNORE TYPE
@ -316,7 +317,7 @@ global PudInfo* GetPudInfo(const char* pud)
exit(-1);
}
if( strcmp(buf,"WAR2 MAP") ) { // ONLY CHECK STRING
fprintf(stderr,"%s: invalid pud\n", pud);
fprintf(stderr,"GetPudInfo: %s: invalid pud\n", pud);
exit(-1);
}
@ -722,11 +723,11 @@ global void LoadPud(const char* pud,WorldMap* map)
}
header[4]='\0';
if( !PudReadHeader(input,header,&length) ) {
fprintf(stderr,"%s: invalid pud\n", pud);
fprintf(stderr,"LoadPud: %s: invalid pud\n", pud);
exit(-1);
}
if( memcmp(header,"TYPE",4) || length!=16 ) {
fprintf(stderr,"%s: invalid pud\n", pud);
fprintf(stderr,"LoadPud: %s: invalid pud\n", pud);
exit(-1);
}
if( CLread(input,buf,16)!=16 ) { // IGNORE TYPE
@ -734,7 +735,7 @@ global void LoadPud(const char* pud,WorldMap* map)
exit(-1);
}
if( strcmp(buf,"WAR2 MAP") ) { // ONLY CHECK STRING
fprintf(stderr,"%s: invalid pud\n", pud);
fprintf(stderr,"LoadPud: %s: invalid pud\n", pud);
exit(-1);
}
@ -942,7 +943,11 @@ global void LoadPud(const char* pud,WorldMap* map)
v=PlayerRaceNeutral;
break;
}
PlayerSetSide(&Players[i],v);
if (GameSettings.Presets[i].Race == SettingsPresetMapDefault) {
PlayerSetSide(&Players[i],v);
} else {
PlayerSetSide(&Players[i],GameSettings.Presets[i].Race);
}
}
continue;
} else {
@ -1113,6 +1118,7 @@ global void LoadPud(const char* pud,WorldMap* map)
int t;
int o;
int v;
int s;
Unit* unit;
while( length>=8 ) {
@ -1128,6 +1134,15 @@ global void LoadPud(const char* pud,WorldMap* map)
Players[o].X=MapOffsetX+x;
Players[o].Y=MapOffsetY+y;
} else {
if ((s = GameSettings.Presets[o].Race) != SettingsPresetMapDefault) {
if (s == PlayerRaceHuman && (t & 1) == 1) {
t--;
}
if (s == PlayerRaceOrc && (t & 1) == 0) {
t++;
}
// FIXME: This is hard-code WCII ... also: support more races..
}
unit=MakeUnitAndPlace(MapOffsetX+x,MapOffsetY+y
,UnitTypeByWcNum(t),&Players[o]);
if( unit->Type->GoldMine || unit->Type->OilPatch ) {

View file

@ -70,19 +70,27 @@ extern int getopt(int argc, char *const*argv, const char *opt);
#include "sound_server.h"
#include "sound.h"
#include "network.h"
#include "pathfinder.h"
#include "spells.h"
#include "settings.h"
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
#ifdef DEBUG
extern unsigned AllocatedGraphicMemory;
extern unsigned CompressedGraphicMemory;
extern SCM CclUnits(void);
#endif
global char* TitleScreen; /// Titlescreen to show at startup
global char* FreeCraftLibPath; /// Path for data
/// Name, Version, Copyright
global char NameLine[] =
"FreeCraft V" VERSION ", (c) 1998-2000 by The FreeCraft Project.";
/// Filename of the map to load
local char* MapName = NULL;
/*----------------------------------------------------------------------------
-- Speedups
----------------------------------------------------------------------------*/
@ -156,134 +164,6 @@ global void SaveAll(void)
fclose(file);
}
/*----------------------------------------------------------------------------
-- INIT
----------------------------------------------------------------------------*/
/**
** Initialise.
**
** Load all graphics, sounds.
*/
global void FreeCraftInit(void)
{
char* PalettePath;
DebugLevel3("Terrain %d\n",TheMap.Terrain);
// FIXME: must use palette from tileset!!
// FIXME: this must be extendable!!
switch( TheMap.Terrain ) {
case TilesetSummer:
PalettePath = strdcat(FreeCraftLibPath, "/summer.rgb");
break;
case TilesetWinter:
PalettePath = strdcat(FreeCraftLibPath, "/winter.rgb");
break;
case TilesetWasteland:
PalettePath = strdcat(FreeCraftLibPath, "/wasteland.rgb");
break;
case TilesetSwamp:
PalettePath = strdcat(FreeCraftLibPath, "/swamp.rgb");
break;
default:
DebugLevel2("Unknown Terrain %d\n",TheMap.Terrain);
PalettePath = strdcat(FreeCraftLibPath, "/summer.rgb");
break;
}
LoadRGB(GlobalPalette, PalettePath);
VideoCreatePalette(GlobalPalette);
//
// Graphic part
//
LoadIcons();
InitMenus(ThisPlayer->Race);
LoadImages(ThisPlayer->Race);
LoadCursors(ThisPlayer->Race);
LoadTileset();
InitUnitButtons();
LoadMissileSprites();
InitSpells();
LoadUnitSprites();
LoadConstructions();
LoadDecorations();
IfDebug(
DebugLevel0("Graphics uses %d bytes (%d KB, %d MB)\n"
,AllocatedGraphicMemory
,AllocatedGraphicMemory/1024
,AllocatedGraphicMemory/1024/1024);
DebugLevel0("Compressed graphics uses %d bytes (%d KB, %d MB)\n"
,CompressedGraphicMemory
,CompressedGraphicMemory/1024
,CompressedGraphicMemory/1024/1024);
);
// FIXME: johns: did this belong into LoadMap?
CreateMinimap(); // create minimap for pud
InitMap(); // setup draw functions
InitMapFogOfWar(); // build tables for fog of war
PreprocessMap(); // Adjust map for use
MapColorCycle(); // Setup color cycle
InitUserInterface(); // Setup the user interface.
//
// Sound part
//
//FIXME: check if everything is really loaded
LoadUnitSounds();
MapUnitSounds();
#ifdef WITH_SOUND
IfDebug(
DebugLevel0("Sounds uses %d bytes (%d KB, %d MB)\n"
,AllocatedSoundMemory
,AllocatedSoundMemory/1024
,AllocatedSoundMemory/1024/1024);
DebugLevel0("Compressed sounds uses %d bytes (%d KB, %d MB)\n"
,CompressedSoundMemory
,CompressedSoundMemory/1024
,CompressedSoundMemory/1024/1024);
);
#endif
//
// Network part
//
InitNetwork();
//
// Init units' groups
//
InitGroups();
//
// Init players?
//
DebugPlayers();
PlayersInitAi();
//
// Upgrades
//
InitUpgrades();
//
// Dependencies
//
InitDependencies();
//
// Buttons (botpanel)
//
InitButtons();
MapCenter(ThisPlayer->X,ThisPlayer->Y);
}
/*----------------------------------------------------------------------------
-- Random
----------------------------------------------------------------------------*/
@ -336,19 +216,8 @@ global char* strdcat3(const char* l, const char* m, const char* r) {
== MAIN
============================================================================*/
global char* TitleScreen; /// Titlescreen show by startup
global char* FreeCraftLibPath; /// Path for data
global int FlagRevealMap; /// Flag must reveal the map
local char* MapName; /// Filename of the map to load
/// Name, Version, Copyright
local char NameLine[] =
"FreeCraft V" VERSION ", (c) 1998-2000 by The FreeCraft Project.";
/**
** Main, called from guile main.
** Main1, called from guile main / main.
**
** @param argc Number of arguments.
** @param argv Vector of arguments.
@ -356,82 +225,6 @@ local char NameLine[] =
global int main1(int argc __attribute__ ((unused)),
char** argv __attribute__ ((unused)))
{
InitVideo(); // setup video display
#ifdef WITH_SOUND
if( InitSound() ) { // setup sound card
SoundOff=1;
SoundFildes=-1;
}
#endif
//
// Show title screen.
//
SetClipping(0,0,VideoWidth,VideoHeight);
if( TitleScreen ) {
DisplayPicture(TitleScreen);
}
Invalidate();
//
// Units Memory Management
//
InitUnitsMemory();
UpdateStats();
InitUnitTypes();
//
// Inital menues require some gfx..
//
LoadRGB(GlobalPalette, strdcat(FreeCraftLibPath, "/summer.rgb"));
VideoCreatePalette(GlobalPalette);
LoadFonts();
// All pre-start menues are orcish - may need to be switched later..
SetDefaultTextColors(FontYellow,FontWhite);
InitMenus(1);
LoadImages(1);
LoadCursors(1);
//
// Load the map.
//
LoadMap(MapName,&TheMap);
if( FlagRevealMap ) {
RevealMap();
}
FreeCraftInit();
#ifdef WITH_SOUND
if (SoundFildes!=-1) {
//FIXME: must be done after map is loaded
if ( InitSoundServer() ) {
SoundOff=1;
SoundFildes=-1;
} else {
// must be done after sounds are loaded
InitSoundClient();
}
}
#endif
//FIXME: must be done after map is loaded
if(AStarOn) {
InitAStar();
}
SetStatusLine(NameLine);
SetMessage("Do it! Do it now!");
if( ThisPlayer->Race==PlayerRaceHuman ) {
SetDefaultTextColors(FontWhite,FontYellow);
// FIXME: Add this again:
// PlaySound(SoundBasicHumanVoicesSelected1);
} else if( ThisPlayer->Race==PlayerRaceOrc ) {
SetDefaultTextColors(FontYellow,FontWhite);
// FIXME: Add this again:
// PlaySound(SoundBasicOrcVoicesSelected1);
}
// FIXME: more races supported
printf("%s\n written by Lutz Sammer, Fabrice Rossi, Vladi Shabanski, Patrice Fortier,\n Jon Gabrielson, Andreas Arens and others."
#ifdef USE_CCL2
@ -482,6 +275,52 @@ This software is provided as-is. The author(s) can not be held liable for any\
Use it at your own risk.\n"
,NameLine);
InitVideo(); // setup video display
#ifdef WITH_SOUND
if( InitSound() ) { // setup sound card
SoundOff=1;
SoundFildes=-1;
}
#endif
//
// Show title screen.
//
SetClipping(0,0,VideoWidth,VideoHeight);
if( TitleScreen ) {
DisplayPicture(TitleScreen);
}
Invalidate();
//
// Units Memory Management
//
InitUnitsMemory();
UpdateStats();
InitUnitTypes();
//
// Inital menues require some gfx..
//
LoadRGB(GlobalPalette, strdcat(FreeCraftLibPath, "/summer.rgb"));
VideoCreatePalette(GlobalPalette);
LoadFonts();
// All pre-start menues are orcish - may need to be switched later..
SetDefaultTextColors(FontYellow,FontWhite);
InitMenus(1);
LoadImages(1);
LoadCursors(1);
InitSettings();
//
// Create the game.
//
CreateGame(MapName,&TheMap);
SetStatusLine(NameLine);
SetMessage("Do it! Do it now!");
GameMainLoop();
return 0;
@ -571,12 +410,9 @@ global int main(int argc,char** argv)
#endif
#if defined(USE_CCL) || defined(USE_CCL2)
CclStartFile="ccl/freecraft.ccl";
MapName="default.cm";
#else
MapName="default.pud"; // .gz/.bz2 automatically appended as needed.
#endif
// FIXME: Parse options before ccl oder after?
// FIXME: Parse options before or after ccl?
//
// Parse commandline
@ -677,9 +513,6 @@ global int main(int argc,char** argv)
--argc;
}
if (MapName[0] != '/' && MapName[0] != '.') {
MapName = strdcat3(FreeCraftLibPath, "/", MapName);
}
#if defined(USE_CCL) || defined(USE_CCL2)
if (CclStartFile[0] != '/' && CclStartFile[0] != '.') {
CclStartFile = strdcat3(FreeCraftLibPath, "/", CclStartFile);

View file

@ -38,6 +38,7 @@
#include "map.h"
#include "pud.h"
#include "iolib.h"
#include "settings.h"
/*----------------------------------------------------------------------------
-- Prototypes for local functions
@ -75,10 +76,15 @@ local void CustomGameCancel(void);
local void CustomGameStart(void);
local void CustomGameDrawFunc(Menuitem *mi);
local void CustomGameRCSAction(Menuitem *mi, int i);
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
/// Name, Version, Copyright
extern char NameLine[];
// FIXME: Johns: this must be all be configured from ccl some time.
/// private struct which specifies the buttons gfx
@ -203,6 +209,8 @@ local Menuitem ScenSelectMenuItems[] = {
** Items for the Prg Start Menu
*/
local Menuitem PrgStartMenuItems[] = {
{ MI_TYPE_TEXT, 640/2, 440, 0, GameFont, NULL, NULL,
{ text:{ NameLine, MI_TFLAGS_CENTERED} } },
{ MI_TYPE_BUTTON, 208, 320, 0, LargeFont, StartMenusSetBackground, NULL,
{ button:{ "~!Single Player Game", 224, 27, MBUTTON_GM_FULL, SinglePlayerGameMenu, 's'} } },
{ MI_TYPE_BUTTON, 208, 320 + 36, MenuButtonDisabled, LargeFont, NULL, NULL,
@ -265,7 +273,7 @@ local Menuitem CustomGameMenuItems[] = {
{ MI_TYPE_TEXT, 40, 10+240-20, 0, GameFont, NULL, NULL,
{ text:{ "~<Your Race:~>", 0} } },
{ MI_TYPE_PULLDOWN, 40, 10+240, 0, GameFont, NULL, NULL,
{ pulldown:{ cgrcsoptions, 152, 20, MBUTTON_PULLDOWN, NULL, 3, 2, 2, 0} } },
{ pulldown:{ cgrcsoptions, 152, 20, MBUTTON_PULLDOWN, CustomGameRCSAction, 3, 2, 2, 0} } },
{ MI_TYPE_TEXT, 220, 10+240-20, 0, GameFont, NULL, NULL,
{ text:{ "~<Resources:~>", 0} } },
{ MI_TYPE_PULLDOWN, 220, 10+240, 0, GameFont, NULL, NULL,
@ -330,7 +338,7 @@ global Menu Menus[] = {
0,
640, 480,
ImageNone,
0, 3,
1, 4,
PrgStartMenuItems
},
{
@ -709,7 +717,11 @@ local void ScenSelectMenu(void)
i = 0;
}
strcat(ScenSelectPath, ScenSelectFileName); // Final map name with path
ScenSelectPudInfo = GetPudInfo(ScenSelectPath);
if (strstr(ScenSelectFileName, ".pud")) {
ScenSelectPudInfo = GetPudInfo(ScenSelectPath);
} else {
// FIXME: GetCmInfo();
}
ScenSelectPath[i] = 0;
}
@ -821,7 +833,12 @@ local int ScenSelectRDFilter(char *pathbuf, FileList *fl)
#endif
if (*cp == 0) {
if (p) {
info = GetPudInfo(pathbuf);
if (strstr(pathbuf, ".pud")) {
info = GetPudInfo(pathbuf);
} else {
info = NULL;
// info = GetCmInfo(pathbuf);
}
if (info) {
sz = szl[ScenSelectMenuItems[8].d.pulldown.curopt];
if (sz < 0 || (info->MapWidth == sz && info->MapHeight == sz)) {
@ -832,6 +849,10 @@ local int ScenSelectRDFilter(char *pathbuf, FileList *fl)
} else {
FreePudInfo(info);
}
} else {
fl->type = 1;
fl->name = strdup(np);
fl->xdata = NULL;
}
} else {
fl->type = 1;
@ -1088,16 +1109,24 @@ local void CustomGameStart(void)
local void CustomGameSetupInit(Menuitem *mi __attribute__((unused)))
{
extern int lcm_prevent_recurse; // FIXME: quickhack
lcm_prevent_recurse = 0;
strcpy(ScenSelectPath, FreeCraftLibPath);
#if 0 // FIXME: as soon as .cm is supported..
#if defined(USE_CCL) || defined(USE_CCL2)
strcpy(ScenSelectFileName, "default.cm");
#else
strcpy(ScenSelectFileName, "default.pud");
#endif
#endif
strcpy(ScenSelectFileName, "default.pud");
if (ScenSelectPath[0]) {
strcat(ScenSelectPath, "/");
}
strcat(ScenSelectPath, ScenSelectFileName); // Final map name with path
ScenSelectPudInfo = GetPudInfo(ScenSelectPath);
if (strstr(ScenSelectFileName, ".pud")) {
ScenSelectPudInfo = GetPudInfo(ScenSelectPath);
} else {
// FIXME: GetCmInfo();
}
strcpy(ScenSelectPath, FreeCraftLibPath);
}
@ -1111,11 +1140,13 @@ local void CustomGameDrawFunc(Menuitem *mi)
SetDefaultTextColors(rc, rc);
DrawText(16, 360, GameFont, "Scenario:");
DrawText(16, 360+24 , GameFont, ScenSelectFileName);
if (ScenSelectPudInfo->Description) {
DrawText(16, 360+24+24, GameFont, ScenSelectPudInfo->Description);
if (ScenSelectPudInfo) {
if (ScenSelectPudInfo->Description) {
DrawText(16, 360+24+24, GameFont, ScenSelectPudInfo->Description);
}
sprintf(buffer, "%d x %d", ScenSelectPudInfo->MapWidth, ScenSelectPudInfo->MapHeight);
DrawText(16, 360+24+24+24, GameFont, buffer);
}
sprintf(buffer, "%d x %d", ScenSelectPudInfo->MapWidth, ScenSelectPudInfo->MapHeight);
DrawText(16, 360+24+24+24, GameFont, buffer);
#if 0
for (n = j = 0; j < 16; j++) {
if (info->PlayerType[j] == PlayerHuman) {
@ -1132,6 +1163,13 @@ local void CustomGameDrawFunc(Menuitem *mi)
SetDefaultTextColors(nc, rc);
}
local void CustomGameRCSAction (Menuitem *mi __attribute__((unused)), int i)
{
int v[] = { PlayerRaceHuman, PlayerRaceOrc, SettingsPresetMapDefault };
GameSettings.Presets[0].Race = v[i];
}
/*----------------------------------------------------------------------------
-- Menu operation functions
----------------------------------------------------------------------------*/
@ -1519,8 +1557,8 @@ global void MenuHandleButtonUp(int b)
MenuButtonUnderCursor = -1;
if (mi->d.pulldown.cursel != mi->d.pulldown.curopt) {
mi->d.pulldown.curopt = mi->d.pulldown.cursel;
if (mi->d.button.handler) {
(*mi->d.button.handler)();
if (mi->d.pulldown.action) {
(*mi->d.pulldown.action)(mi, mi->d.pulldown.curopt);
}
}
}