24 #include "C4Version.h"
47 const std::string C4Application::Revision{ C4REVISION };
50 IRCClient(ApplicationIRCClient)
67 for (int32_t iPar=0; iPar < argc; iPar++)
69 sConfigFilename.
Copy(argv[iPar] + 9);
81 Log(
"ERROR: Custom configuration corrupted - program abort!\n");
87 Log(
"Warning: Configuration corrupted - restoring default!\n");
120 const char *szMessage =
"Error opening system group file (System.ocg)!";
138 Log(
"WARNING: No language string table loaded!");
140 #if defined(WIN32) && defined(WITH_AUTOMATIC_UPDATE)
164 {
Clear();
return false; }
198 for(
int i = 0; i < argc; ++i) {
211 static struct option long_options[] =
214 {
"editor", no_argument, &
isEditor, 1},
215 {
"fullscreen", no_argument, &
isEditor, 0},
225 {
"debugrecread", required_argument,
nullptr,
'K'},
226 {
"debugrecwrite", required_argument,
nullptr,
'w'},
228 {
"client", required_argument,
nullptr,
'c'},
229 {
"host", no_argument,
nullptr,
'h'},
230 {
"debughost", required_argument,
nullptr,
'H'},
231 {
"debugpass", required_argument,
nullptr,
'P'},
232 {
"debug", required_argument,
nullptr,
'D'},
233 {
"data", required_argument,
nullptr,
'd'},
234 {
"startup", required_argument,
nullptr,
's'},
235 {
"stream", required_argument,
nullptr,
'e'},
236 {
"recdump", required_argument,
nullptr,
'R'},
237 {
"comment", required_argument,
nullptr,
'm'},
238 {
"pass", required_argument,
nullptr,
'p'},
239 {
"udpport", required_argument,
nullptr,
'u'},
240 {
"tcpport", required_argument,
nullptr,
't'},
241 {
"join", required_argument,
nullptr,
'j'},
242 {
"language", required_argument,
nullptr,
'L'},
243 {
"scenpar", required_argument,
nullptr,
'S'},
245 {
"observe", no_argument,
nullptr,
'o'},
246 {
"nonetwork", no_argument,
nullptr,
'N'},
247 {
"network", no_argument,
nullptr,
'n'},
248 {
"record", no_argument,
nullptr,
'r'},
250 {
"lobby", optional_argument,
nullptr,
'l'},
253 {
"config", required_argument,
nullptr, 0},
254 {
"show-licenses", no_argument,
nullptr, 0},
255 {
nullptr, 0,
nullptr, 0}
257 int option_index = 0;
258 c = getopt_long (argc, argv,
"abc:d:f:",
259 long_options, &option_index);
267 if (
SEqualNoCase(long_options[option_index].name,
"signup"))
272 if (
SEqualNoCase(long_options[option_index].name,
"league"))
278 if (
SEqualNoCase(long_options[option_index].name,
"show-licenses"))
280 std::string sep{
"\n=================================\n"};
282 Log((sep + license.path +
": " + license.name + sep + license.content +
"\n").c_str());
304 if (optarg && optarg[0])
306 LogF(
"Reading from DebugRec file '%s'", optarg);
310 Log(
"Reading DebugRec from CtrlRec file in scenario record");
315 if (optarg && optarg[0])
317 LogF(
"Writing to DebugRec file '%s'", optarg);
321 Log(
"Writing DebugRec to CtrlRec file in scenario record");
374 default: assert(!
"unexpected getopt_long return value");
382 while (optind < argc)
384 char * szParameter = argv[optind++];
386 int iLen =
SLen(szParameter);
387 if (iLen > 5 && szParameter[iLen-1] ==
'/' && szParameter[iLen-5] ==
'.' && szParameter[iLen-4] ==
'o' && szParameter[iLen-3] ==
'c')
389 szParameter[iLen-1] =
'\0';
454 const char* install_mod_command =
"installmod";
455 const auto install_mod_command_length = strlen(install_mod_command);
501 int32_t idx = -1, iXRes, iYRes, iBitDepth, iRefreshRate;
502 int32_t best_match = -1;
503 uint32_t best_delta = ~0;
510 if (delta < best_delta)
517 if (best_match != -1)
576 if (fUseStartupDialog)
707 #ifdef WITH_QT_EDITOR
739 if (!NextMission.empty())
811 if (!szFontFace || !*szFontFace || iFontSize<1 ||
SLen(szFontFace)>=
static_cast<int>(
sizeof Config.
General.
RXFontName))
return false;
848 #ifdef USE_WIN32_WINDOWS
857 if (szMissionFilename)
859 NextMission = szMissionFilename;
895 iGameTickDelay = iDelay;
902 iExtraGameTickDelay = 0;
909 iExtraGameTickDelay = iDelay;
916 if (!CheckAndReset())
return true;
919 if (tNow >= tLastGameTick + iExtraGameTickDelay ||
Game.
GameGo)
922 tLastGameTick += iGameTickDelay;
924 tLastGameTick = tNow;
927 if (tNow > tLastGameTick + iGameTickDelay)
928 tLastGameTick += (tNow - tLastGameTick) / 2;
bool DDrawInit(C4AbstractApp *pApp, unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor)
void ShowGfxErrorDialog()
C4Application Application
C4GraphicsSystem GraphicsSystem
C4GraphicsResource GraphicsResource
void C4Group_SetTempPath(const char *path)
void C4Group_SetSortList(const char **sort_list)
void C4Group_SetProcessCallback(bool(*callback)(const char *, int))
const char * LoadResStr(const char *id)
const std::vector< OCLicenseInfo > OCLicenses
bool Log(const char *szMessage)
bool LogF(const char *strMessage,...)
bool LogFatal(const char *szMessage)
#define C4CFN_StartupBackgroundMain
void SReplaceChar(char *str, char fc, char tc)
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
int SClearFrontBack(char *szString, char cClear)
bool SAddModule(char *szList, const char *szModule, bool fCaseSensitive)
bool SEqual2NoCase(const char *szStr1, const char *szStr2, int iLen)
const char * SAdvancePast(const char *szSPos, char cPast)
size_t SLen(const char *sptr)
char * GetExtension(char *szFilename)
char * GetFilename(char *szPath)
bool IsGlobalPath(const char *szPath)
const char * GetWorkingDirectory()
#define CStdMultimediaTimerProc
void MessageDialog(const char *message)
bool SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
bool GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32_t *piYRes, int32_t *piBitDepth, int32_t *piRefreshRate, uint32_t iMonitor)
bool Execute(int iTimeout, pollfd *) override
bool IsLowPriority() override
void SetGameTickDelay(uint32_t iDelay)
std::string IncomingUpdate
static bool ProcessCallback(const char *szMessage, int iProcess)
void OnKeyboardLayoutChanged() override
bool DoInit(int argc, char *argv[]) override
void ApplyResolutionConstraints()
C4MusicSystem MusicSystem
void OpenGame(const char *scenario=nullptr)
C4ApplicationGameTimer * pGameTimer
enum C4Application::State C4AS_None
std::string IncomingKeyfile
C4GamePadControl * pGamePadControl
void SetNextMission(const char *szMissionFilename)
void SetGameTickDelay(int iDelay)
void OnResolutionChanged(unsigned int iXRes, unsigned int iYRes) override
C4Network2IRCClient & IRCClient
C4SoundSystem SoundSystem
void ParseCommandLine(int argc, char *argv[])
void OnCommand(const char *szCmd) override
bool SetGameFont(const char *szFontFace, int32_t iFontSize)
const char * GetRevision() const
~C4Application() override
char SystemDataPath[CFG_MaxString+1]
char LanguageEx[CFG_MaxString+1]
char DebugRecExternalFile[_MAX_PATH_LEN]
char UserDataPath[CFG_MaxString+1]
int32_t OpenScenarioInGameMode
char RXFontName[CFG_MaxString+1]
int32_t ShowStartupMessages
void CleanupTempUpdateFolder()
bool Load(const char *config_file=nullptr)
C4ConfigGraphics Graphics
ValidatedStdCopyStrBuf< C4InVal::VAL_Comment > Comment
int32_t MasterServerSignUp
int32_t LeagueServerSignUp
void Out(const char *message)
virtual C4Window * Init(C4AbstractApp *app)
static constexpr int COLOR_DEPTH
virtual bool OnResolutionChanged(unsigned int iXRes, unsigned int iYRes)=0
void Set(C4Surface &rSfc)
bool InitFont(CStdFont *Font, const char *szFontName, FontType eType, int32_t iSize, C4GroupSet *pGfxGroups, bool fDoShadow=true)
C4Window * Init(C4AbstractApp *application)
void OnResolutionChanged(unsigned int res_x, unsigned int res_y)
char PlayerFilenames[20 *_MAX_PATH_LEN]
char DirectJoinAddress[_MAX_PATH_LEN]
void SetScenarioFilename(const char *)
void SetInitProgress(float to_progress)
char ScenarioFilename[_MAX_PATH_LEN]
class C4ScenarioParameters & StartupScenarioParameters
void OnKeyboardLayoutChanged()
C4GameParameters & Parameters
char DefinitionFilenames[20 *_MAX_PATH_LEN]
bool InitLoaderScreen(const char *image_name)
std::unique_ptr< C4MessageBoard > MessageBoard
bool LoadLanguage(const char *strLanguages)
bool HasStringTable() const
bool Play(const char *szSongname=nullptr, bool fLoop=false, int fadetime_ms=0, double max_resume_time=0.0, bool allow_break=false)
bool Init(const char *PlayList=nullptr)
void Execute(bool force_buffer_checks=false)
void SetPassword(const char *szToPassword)
bool AddPath(const char *path, PathType pathType=PATH_Regular)
bool Open(C4Group &group, const char *filename) const
void SetValue(const char *id, int32_t value, bool only_if_larger)
void OnKeyboardLayoutChanged()
C4StartupGraphics Graphics
static bool SetStartScreen(const char *szScreen, const char *szSubDialog=nullptr)
static void InitStartup()
static void CloseStartup()
bool UpdateSize(int wdt, int hgt)
static C4TimeMilliseconds Now()
bool GetSize(C4Rect *pRect)
void SetSize(unsigned int cx, unsigned int cy)
void GrabMouse(bool grab)
static void WaitForSaves()
void Remove(StdSchedulerProc *pProc)
void Add(StdSchedulerProc *pProc)
const char * getData() const
bool SplitAtChar(char cSplit, StdStrBuf *psSplit)
void Append(const char *pnData, size_t iChars)
int ReplaceChar(char cOld, char cNew)
void CopyValidated(const char *szFromVal)