Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
urlBuilder.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include <string>
20#include <stdio.h>
21#include "registry.h"
22
23void FormatURLFromRegistry( std::string& gamePatchURL, std::string& mapPatchURL,
24 std::string& configURL, std::string& motdURL )
25{
26 std::string sku = "GeneralsZH";
27 std::string language = "english";
28 unsigned int version = 0; // invalid version - can't get on with a corrupt reg.
29 unsigned int mapVersion = 0; // invalid version - can't get on with a corrupt reg.
30 std::string baseURL = "http://servserv.generals.ea.com/servserv/";
31 baseURL.append(sku);
32 baseURL.append("/");
33
34 GetStringFromRegistry("", "BaseURL", baseURL);
35 GetStringFromRegistry("", "Language", language);
36 GetUnsignedIntFromRegistry("", "Version", version);
37 GetUnsignedIntFromRegistry("", "MapPackVersion", mapVersion);
38
39 char buf[256];
40 _snprintf(buf, 256, "%s%s-%d.txt", baseURL.c_str(), language.c_str(), version);
41 gamePatchURL = buf;
42 _snprintf(buf, 256, "%smaps-%d.txt", baseURL.c_str(), mapVersion);
43 mapPatchURL = buf;
44 _snprintf(buf, 256, "%sconfig.txt", baseURL.c_str());
45 configURL = buf;
46 _snprintf(buf, 256, "%sMOTD-%s.txt", baseURL.c_str(), language.c_str());
47 motdURL = buf;
48}
49
Bool GetStringFromRegistry(AsciiString path, AsciiString key, AsciiString &val)
Definition registry.cpp:135
Bool GetUnsignedIntFromRegistry(AsciiString path, AsciiString key, UnsignedInt &val)
Definition registry.cpp:149
void FormatURLFromRegistry(std::string &gamePatchURL, std::string &mapPatchURL, std::string &configURL, std::string &motdURL)