2010-03-16 21:44:22 +00:00
|
|
|
#ifndef _GLEST_GAME_GAMECONSTANTS_H_
|
|
|
|
#define _GLEST_GAME_GAMECONSTANTS_H_
|
|
|
|
|
2010-03-25 12:15:10 +00:00
|
|
|
#include <cassert>
|
2010-03-27 02:22:14 +00:00
|
|
|
#include <stdio.h>
|
2010-10-23 09:06:47 +00:00
|
|
|
#include "vec.h"
|
2012-03-31 05:54:24 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2012-09-22 20:13:57 +00:00
|
|
|
#include "conversion.h"
|
2012-03-31 05:54:24 +00:00
|
|
|
#include <stdexcept>
|
2010-03-25 12:15:10 +00:00
|
|
|
|
2010-03-16 21:44:22 +00:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
//
|
2010-10-23 09:06:47 +00:00
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
2010-03-16 21:44:22 +00:00
|
|
|
//
|
|
|
|
// You can redistribute this code 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
|
|
|
|
// ==============================================================
|
|
|
|
|
2010-10-23 09:06:47 +00:00
|
|
|
using namespace Shared::Graphics;
|
2012-03-31 05:54:24 +00:00
|
|
|
using namespace std;
|
2012-09-22 20:13:57 +00:00
|
|
|
using namespace Shared::Util;
|
2010-10-23 09:06:47 +00:00
|
|
|
|
2010-03-16 21:44:22 +00:00
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
2012-03-31 05:54:24 +00:00
|
|
|
template<typename T>
|
|
|
|
class EnumParser {
|
|
|
|
private:
|
|
|
|
typedef map<string, T> enumMapType;
|
|
|
|
typedef typename enumMapType::const_iterator enumMapTypeIter;
|
|
|
|
EnumParser();
|
|
|
|
|
|
|
|
enumMapType enumMap;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static T getEnum(const string &value) {
|
|
|
|
static EnumParser<T> parser;
|
|
|
|
enumMapTypeIter iValue = parser.enumMap.find(value);
|
|
|
|
if(iValue == parser.enumMap.end()) {
|
|
|
|
throw std::runtime_error("unknown enum lookup [" + value + "]");
|
|
|
|
}
|
|
|
|
return iValue->second;
|
|
|
|
}
|
|
|
|
static string getString(const T &value) {
|
|
|
|
static EnumParser<T> parser;
|
|
|
|
for(enumMapTypeIter iValue = parser.enumMap.first();
|
|
|
|
iValue != parser.enumMap.end(); ++iValue) {
|
|
|
|
if(iValue->second == value) {
|
|
|
|
return iValue->first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw std::runtime_error("unknown enum lookup [" + intToStr(value) + "]");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-03-16 21:44:22 +00:00
|
|
|
// =====================================================
|
|
|
|
// class GameConstants
|
|
|
|
// =====================================================
|
|
|
|
|
2010-10-27 17:06:40 +00:00
|
|
|
const Vec4f BLACK(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
const Vec4f RED(1.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
const Vec4f GREEN(0.0f, 1.0f, 0.0f, 1.0f);
|
|
|
|
const Vec4f BLUE(0.0f, 0.0f, 1.0f, 1.0f);
|
|
|
|
const Vec4f GLASS(1.0f, 1.0f, 1.0f, 0.3f);
|
|
|
|
const Vec4f CYAN(0.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
const Vec4f YELLOW(1.0f, 1.0f, 0.0f, 1.0f);
|
|
|
|
const Vec4f MAGENTA(1.0f, 0.0f, 1.0f, 1.0f);
|
|
|
|
const Vec4f WHITE(1.0f, 1.0f, 1.0f, 1.0f);
|
2011-10-18 22:00:59 +00:00
|
|
|
const Vec4f ORANGE(1.0f, 0.7f, 0.0f, 1.0f);
|
2010-10-23 09:06:47 +00:00
|
|
|
|
2010-07-21 18:21:40 +00:00
|
|
|
enum PathFinderType {
|
2012-09-22 21:39:13 +00:00
|
|
|
pfBasic
|
2010-07-21 18:21:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum TravelState {
|
|
|
|
tsArrived,
|
|
|
|
tsMoving,
|
|
|
|
tsBlocked,
|
|
|
|
tsImpossible
|
|
|
|
};
|
|
|
|
|
2010-09-14 19:10:37 +00:00
|
|
|
enum ControlType {
|
2010-03-16 21:44:22 +00:00
|
|
|
ctClosed,
|
|
|
|
ctCpuEasy,
|
|
|
|
ctCpu,
|
|
|
|
ctCpuUltra,
|
|
|
|
ctCpuMega,
|
|
|
|
ctNetwork,
|
2011-09-01 21:54:31 +00:00
|
|
|
ctNetworkUnassigned,
|
2010-09-14 19:10:37 +00:00
|
|
|
ctHuman,
|
|
|
|
|
|
|
|
ctNetworkCpuEasy,
|
|
|
|
ctNetworkCpu,
|
|
|
|
ctNetworkCpuUltra,
|
|
|
|
ctNetworkCpuMega
|
|
|
|
|
2010-03-16 21:44:22 +00:00
|
|
|
};
|
|
|
|
|
2010-09-14 19:10:37 +00:00
|
|
|
enum NetworkRole {
|
|
|
|
nrServer,
|
|
|
|
nrClient,
|
|
|
|
nrIdle
|
|
|
|
};
|
2010-09-04 00:32:56 +00:00
|
|
|
|
|
|
|
enum FactionPersonalityType {
|
|
|
|
fpt_Normal,
|
|
|
|
fpt_Observer,
|
|
|
|
|
|
|
|
fpt_EndCount
|
|
|
|
};
|
|
|
|
|
2011-01-25 07:41:12 +00:00
|
|
|
enum MasterServerGameStatusType {
|
|
|
|
game_status_waiting_for_players = 0,
|
|
|
|
game_status_waiting_for_start = 1,
|
|
|
|
game_status_in_progress = 2,
|
|
|
|
game_status_finished = 3
|
|
|
|
};
|
|
|
|
|
2010-03-16 21:44:22 +00:00
|
|
|
class GameConstants {
|
|
|
|
public:
|
2010-09-04 00:32:56 +00:00
|
|
|
static const int specialFactions = fpt_EndCount - 1;
|
2010-03-16 21:44:22 +00:00
|
|
|
static const int maxPlayers= 8;
|
|
|
|
static const int serverPort= 61357;
|
2012-03-25 06:55:43 +00:00
|
|
|
static const int serverAdminPort= 61355;
|
2010-08-25 18:26:17 +00:00
|
|
|
//static const int updateFps= 40;
|
|
|
|
//static const int cameraFps= 100;
|
|
|
|
static int updateFps;
|
|
|
|
static int cameraFps;
|
|
|
|
|
2010-06-05 07:52:14 +00:00
|
|
|
static int networkFramePeriod;
|
2010-07-09 17:12:57 +00:00
|
|
|
static const int networkPingInterval = 5;
|
2013-04-07 15:27:55 +00:00
|
|
|
static const int networkSmoothInterval= 30;
|
2010-06-05 07:52:14 +00:00
|
|
|
//static const int networkExtraLatency= 200;
|
2010-05-12 15:25:56 +00:00
|
|
|
static const int maxClientConnectHandshakeSecs= 10;
|
2010-03-16 21:44:22 +00:00
|
|
|
|
2010-07-11 18:31:02 +00:00
|
|
|
static const int cellScale = 2;
|
|
|
|
static const int clusterSize = 16;
|
|
|
|
|
2010-03-16 21:44:22 +00:00
|
|
|
static const char *folder_path_maps;
|
|
|
|
static const char *folder_path_scenarios;
|
|
|
|
static const char *folder_path_techs;
|
|
|
|
static const char *folder_path_tilesets;
|
|
|
|
static const char *folder_path_tutorials;
|
2010-06-29 06:50:35 +00:00
|
|
|
|
|
|
|
static const char *NETWORK_SLOT_UNCONNECTED_SLOTNAME;
|
2010-08-02 03:15:11 +00:00
|
|
|
|
|
|
|
static const char *folder_path_screenshots;
|
2010-09-04 00:32:56 +00:00
|
|
|
|
|
|
|
static const char *OBSERVER_SLOTNAME;
|
2010-09-11 08:09:33 +00:00
|
|
|
static const char *RANDOMFACTION_SLOTNAME;
|
2010-10-22 07:28:55 +00:00
|
|
|
|
2013-11-10 19:47:04 +00:00
|
|
|
static const char *preCacheThreadCacheLookupKey;
|
2010-10-22 07:28:55 +00:00
|
|
|
static const char *playerTextureCacheLookupKey;
|
2012-11-15 08:16:08 +00:00
|
|
|
static const char *ircClientCacheLookupKey;
|
2011-01-26 09:09:59 +00:00
|
|
|
static const char *factionPreviewTextureCacheLookupKey;
|
2011-11-15 04:48:57 +00:00
|
|
|
static const char *characterMenuScreenPositionListCacheLookupKey;
|
2010-12-09 20:41:11 +00:00
|
|
|
static const char *pathCacheLookupKey;
|
|
|
|
static const char *path_data_CacheLookupKey;
|
|
|
|
static const char *path_ini_CacheLookupKey;
|
|
|
|
static const char *path_logs_CacheLookupKey;
|
2010-11-05 06:46:30 +00:00
|
|
|
|
|
|
|
static const char *application_name;
|
2010-12-11 00:20:31 +00:00
|
|
|
|
2013-05-01 20:56:19 +00:00
|
|
|
static const char *saveNetworkGameFileServerCompressed;
|
2013-02-16 19:11:36 +00:00
|
|
|
static const char *saveNetworkGameFileServer;
|
2013-05-01 20:56:19 +00:00
|
|
|
static const char *saveNetworkGameFileClientCompressed;
|
2013-02-16 19:11:36 +00:00
|
|
|
static const char *saveNetworkGameFileClient;
|
2012-03-10 03:27:25 +00:00
|
|
|
static const char *saveGameFileDefault;
|
2012-03-17 08:20:17 +00:00
|
|
|
static const char *saveGameFileAutoTestDefault;
|
2012-03-15 15:57:21 +00:00
|
|
|
static const char *saveGameFilePattern;
|
2012-03-10 03:27:25 +00:00
|
|
|
|
2010-12-11 08:00:49 +00:00
|
|
|
// VC++ Chokes on init of non integral static types
|
|
|
|
static const float normalMultiplier;
|
|
|
|
static const float easyMultiplier;
|
|
|
|
static const float ultraMultiplier;
|
|
|
|
static const float megaMultiplier;
|
|
|
|
//
|
2010-12-11 00:20:31 +00:00
|
|
|
|
2013-02-11 23:43:30 +00:00
|
|
|
static const char * LOADING_SCREEN_FILE;
|
|
|
|
static const char * LOADING_SCREEN_FILE_FILTER;
|
|
|
|
static const char * PREVIEW_SCREEN_FILE;
|
|
|
|
static const char * PREVIEW_SCREEN_FILE_FILTER;
|
|
|
|
static const char * HUD_SCREEN_FILE;
|
|
|
|
static const char * HUD_SCREEN_FILE_FILTER;
|
|
|
|
|
2010-03-16 21:44:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum PathType {
|
|
|
|
ptMaps,
|
|
|
|
ptScenarios,
|
|
|
|
ptTechs,
|
|
|
|
ptTilesets,
|
|
|
|
ptTutorials
|
|
|
|
};
|
|
|
|
|
2010-03-25 12:15:10 +00:00
|
|
|
struct CardinalDir {
|
|
|
|
public:
|
2010-07-13 05:33:43 +00:00
|
|
|
enum Enum { NORTH, EAST, SOUTH, WEST, COUNT };
|
2010-03-25 12:15:10 +00:00
|
|
|
|
|
|
|
CardinalDir() : value(NORTH) {}
|
|
|
|
CardinalDir(Enum v) : value(v) {}
|
|
|
|
explicit CardinalDir(int v) {
|
2010-04-27 03:36:36 +00:00
|
|
|
assertDirValid(v);
|
2010-03-25 12:15:10 +00:00
|
|
|
value = static_cast<Enum>(v);
|
|
|
|
}
|
2010-05-18 03:53:57 +00:00
|
|
|
operator Enum() const { return value; }
|
|
|
|
int asInt() const { return (int)value; }
|
2010-03-16 21:44:22 +00:00
|
|
|
|
2010-04-27 03:36:36 +00:00
|
|
|
static void assertDirValid(int v) { assert(v >= 0 && v < 4); }
|
2010-03-25 12:15:10 +00:00
|
|
|
void operator++() {
|
2010-03-27 02:22:14 +00:00
|
|
|
//printf("In [%s::%s] Line: %d BEFORE +: value = %d\n",__FILE__,__FUNCTION__,__LINE__,asInt());
|
|
|
|
value = static_cast<Enum>((value + 1) % 4);
|
|
|
|
//printf("In [%s::%s] Line: %d AFTER +: value = %d\n",__FILE__,__FUNCTION__,__LINE__,asInt());
|
2010-03-25 12:15:10 +00:00
|
|
|
}
|
|
|
|
void operator--() { // mod with negative numbers is a 'grey area', hence the +3 rather than -1
|
2010-03-27 02:22:14 +00:00
|
|
|
value = static_cast<Enum>((value + 3) % 4);
|
2010-03-25 12:15:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Enum value;
|
|
|
|
};
|
2010-03-16 21:44:22 +00:00
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
#endif
|