Fix compilation errors

This commit is contained in:
dP
2024-02-04 03:50:22 +05:30
parent 7a1afa55d6
commit 7e2ce7a494
37 changed files with 74 additions and 1656 deletions

View File

@@ -1,8 +0,0 @@
rem
rem Building language files...
rem
cd ..
strgen\strgen
for %%f in (lang\*.txt) do strgen\strgen %%f
cd strgen

View File

@@ -1 +0,0 @@
start /n /win openttd.exe -D %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@@ -1,21 +0,0 @@
@echo off
if "%1" == "" goto err
if "%2" == "" goto err
echo Downloading NoSound...
%1\wget http://binaries.openttd.org/installer/nosound-NOSOUND_VERSION.7z -O %2/baseset/nosound.7z
echo Extracting NoSound...
%1\7za x -y -O%2/baseset %2/baseset/nosound.7z
del %1\baseset\nosound.7z /n
echo NoSound has been installed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
echo Please visit www.openttd.org for details on downloading NoSound.
:end

View File

@@ -1,21 +0,0 @@
@echo off
if "%1" == "" goto err
if "%2" == "" goto err
echo Downloading OpenGFX...
%1\wget http://binaries.openttd.org/installer/opengfx-OPENGFX_VERSION.7z -O %2/baseset/opengfx.7z
echo Extracting OpenGFX...
%1\7za x -y -O%2/baseset %2/baseset/opengfx.7z
del %1\baseset\opengfx.7z /n
echo OpenGFX has been installed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
echo Please visit www.openttd.org for details on downloading OpenGFX.
:end

View File

@@ -1,21 +0,0 @@
@echo off
if "%1" == "" goto err
if "%2" == "" goto err
echo Downloading OpenSFX...
%1\wget http://binaries.openttd.org/installer/opensfx-OPENSFX_VERSION.7z -O %2/baseset/opensfx.7z
echo Extracting OpenSFX...
%1\7za x -y -O%2/baseset %2/baseset/opensfx.7z
del %1\baseset\opensfx.7z /n
echo OpenSFX has been installed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
echo Please visit www.openttd.org for details on downloading OpenSFX.
:end

View File

@@ -1,85 +0,0 @@
@echo off
set OPENTTD_VERSION=1.11.0
set OPENSFX_VERSION=0.8.0
set NOSOUND_VERSION=0.8.0
set OPENGFX_VERSION=1.2.0
echo To make the installer, you must have the WarpIN compiler (wic) installed and in
echo your path, as well as wget and unzip. This file will download the various DLLs
echo to be distributed with the installer. If you do not want to continue, please
echo press CTRL-C now.
echo.
pause
cd ..\..\..\bundle
if not exist SDL12.dll goto getsdl
if not exist FSLib.dll goto getsdl
goto libc
:getsdl
wget http://www.os2site.com/sw/dev/sdl/sdl-1.2.10-bin-20080804.zip -O dl.zip
unzip -j dl.zip SDL/FSLib.dll SDL/SDL12.dll
del dl.zip
:libc
if exist libc063.dll goto gcc
wget ftp://ftp.netlabs.org/pub/gcc/libc-0.6.3-csd3.zip -O dl.zip
unzip -j dl.zip libc063.dll
del dl.zip
:gcc
if exist gcc442.dll goto tools
wget http://www.owenrudge.net/various/gcc442.zip -O dl.zip
unzip -j dl.zip gcc442.dll
del dl.zip
:tools
cd ..\os\os2\installer
if exist tools goto opengfx
mkdir tools
cd tools
wget http://download.smedley.info/wget-1.11.4-os2-20090315.zip -O dl.zip
unzip -j dl.zip wget/bin/wget.exe
del dl.zip
wget ftp://ftp.os4.su/moveton/p7zip-9.04-bin-os2.zip -O dl.zip
unzip -j dl.zip bin/7za.exe dll/ilibca.dll
del dl.zip
cd ..
:opengfx
if exist opengfx goto opensfx
mkdir opengfx
sed s/OPENGFX_VERSION/%OPENGFX_VERSION%/ < download_opengfx.cmd > opengfx\download_opengfx.cmd
copy remove_opengfx.cmd opengfx
:opensfx
if exist opensfx goto nosound
mkdir opensfx
sed s/OPENSFX_VERSION/%OPENSFX_VERSION%/ < download_opensfx.cmd > opensfx\download_opensfx.cmd
copy remove_opensfx.cmd opensfx
:nosound
mkdir nosound
sed s/NOSOUND_VERSION/%NOSOUND_VERSION%/ < download_nosound.cmd > nosound\download_nosound.cmd
copy remove_nosound.cmd nosound
:end
if exist openttd-%OPENTTD_VERSION%-os2.exe del openttd-%OPENTTD_VERSION%-os2.exe
wic -a openttd-%OPENTTD_VERSION%-os2.exe 1 -c../../../bundle -r * 2 -ctools -r * 3 -copengfx -r * 4 -copensfx -r * 5 -cnosound -r * -U -s openttd.wis

View File

@@ -1,106 +0,0 @@
<WARPIN>
<HEAD>
<TITLE>OpenTTD</TITLE>
<!-- Please remember to increment the build number for each package
when releasing a new stable version, particularly if there are
also release candidates sharing the major/minor versions:
e.g., 0\7\1\16279 for 0.7.1-RC1,
0\7\1\16365 for 0.7.1-RC2,
0\7\1\16540 for 0.7.1 final
-->
<PCK INDEX="1"
PACKAGEID="OpenTTD\OpenTTD\OpenTTD\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="OpenTTD"
LONGFILENAMES
BASE
>OpenTTD is an open source transport simulation game</PCK>
<PCK INDEX="2"
PACKAGEID="OpenTTD\OpenTTD\Downloader\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="Download tools"
REQUIRES=1
FIXED
>Tools required for downloading the OpenGFX/SFX packs</PCK>
<PCK INDEX="3"
PACKAGEID="OpenTTD\OpenTTD\OpenGFX\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="OpenGFX"
LONGFILENAMES
REQUIRES=2
EXECUTE="$(3)\download_opengfx.cmd | $(1) $(/1)"
DEEXECUTE="$(3)\remove_opengfx.cmd | $(1) $(/1)"
FIXED
>Downloads the OpenGFX graphics pack for OpenTTD</PCK>
<PCK INDEX="4"
PACKAGEID="OpenTTD\OpenTTD\OpenSFX\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="OpenSFX"
LONGFILENAMES
REQUIRES=2
EXECUTE="$(4)\download_opensfx.cmd | $(1) $(/1)"
DEEXECUTE="$(4)\remove_opensfx.cmd | $(1) $(/1)"
FIXED
>Downloads the OpenSFX sound effects pack for OpenTTD</PCK>
<PCK INDEX="5"
PACKAGEID="OpenTTD\OpenTTD\NoSound\1\0\0\18862"
TARGET="$(WARPIN_DEFAULTAPPSPATH)\OpenTTD"
SELECT
TITLE="NoSound"
LONGFILENAMES
REQUIRES=2
EXECUTE="$(5)\download_nosound.cmd | $(1) $(/1)"
DEEXECUTE="$(5)\remove_nosound.cmd | $(1) $(/1)"
FIXED
>Downloads the NoSound pack for OpenTTD, to disable sound effects</PCK>
</HEAD>
<BODY>
<!-- page 1: introductory page -->
<PAGE INDEX="1" TYPE="README">
<NEXTBUTTON TARGET=2>~Next</NEXTBUTTON>
<README EXTRACTFROMPCK="1">README.md</README>
<TEXT>Welcome to the OpenTTD installer. This program will install OpenTTD 1.0 on your system. Before we begin the installation process, please take a moment to read the following document.
Select "Next" to continue, or "Cancel" to abort installation.</TEXT>
</PAGE>
<!-- page 2: licence page -->
<PAGE INDEX="2" TYPE="README">
<NEXTBUTTON TARGET=3>~Next</NEXTBUTTON>
<README EXTRACTFROMPCK="1">COPYING.md</README>
<TEXT>OpenTTD is licenced under the GNU General Public License. The text of the licence is below.
Select "Next" if you agree to this licence.
Select "Cancel" to abort installation.</TEXT>
</PAGE>
<!-- The TYPE=CONTAINER will list the packages which can be installed. -->
<PAGE INDEX="3" TYPE="CONTAINER">
<NEXTBUTTON TARGET="4">~Next</NEXTBUTTON>
<TEXT>On this page, you may choose which components to install. If you don't own Transport Tycoon Deluxe, you will need to download OpenGFX (3MiB) and OpenSFX (10MiB).</TEXT>
</PAGE>
<!-- Display another TEXT page to inform the user
that installation will begin. We use the TARGET=0
with the NEXTBUTTON tag which starts installation. -->
<PAGE INDEX="4" TYPE="TEXT">
<NEXTBUTTON TARGET="0">I~nstall</NEXTBUTTON>
<TEXT>
Press "Install" to begin installing OpenTTD.</TEXT>
</PAGE>
</BODY>
</WARPIN>

View File

@@ -1,15 +0,0 @@
@echo off
if "%1" == "" goto err
echo Removing NoSound...
del %1\baseset\nosound\*.* /n
rmdir %1\baseset\nosound
echo NoSound has been removed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
:end

View File

@@ -1,15 +0,0 @@
@echo off
if "%1" == "" goto err
echo Removing OpenGFX...
del %1\baseset\opengfx\*.* /n
rmdir %1\baseset\opengfx
echo OpenGFX has been removed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
:end

View File

@@ -1,15 +0,0 @@
@echo off
if "%1" == "" goto err
echo Removing OpenSFX...
del %1\baseset\opensfx\*.* /n
rmdir %1\baseset\opensfx
echo OpenSFX has been removed.
goto end
:err
echo This batch file is only intended for use by the OpenTTD installer.
:end

View File

@@ -1,64 +0,0 @@
40
projectIdent
0
VpeMain
1
WRect
0
0
10304
10020
2
MProject
3
MCommand
15
svn_version.cmd
4
MCommand
0
2
5
WFileName
17
..\..\openttd.tgt
6
WFileName
23
..\..\strgen\strgen.tgt
7
WVList
2
8
VComponent
9
WRect
0
0
5696
4240
0
0
10
WFileName
17
..\..\openttd.tgt
0
0
11
VComponent
12
WRect
688
680
5696
4240
0
0
13
WFileName
23
..\..\strgen\strgen.tgt
0
1
8

View File

@@ -1,30 +0,0 @@
@echo off
echo Running SVN version detection script...
rem
rem Requires subversion (`svnversion') to be installed
rem
cd ..\..
if not "%RELEASE%"=="" goto forcerelease
if not exist .svn goto nosvn
svnversion -n . > os\os2\svnver.tmp
if not "%ERRORLEVEL%"=="0" goto nosvn
copy os\os2\svnver1.c+os\os2\svnver.tmp+os\os2\svnver2.c rev.c /a /y > nul 2> nul
goto end
:forcerelease
echo Forcing release string "%RELEASE%"...
echo const char _openttd_revision[] = "%RELEASE%"; > rev.c
echo const int _revision_number = 0; >> rev.c
goto end
:nosvn
echo Error executing `svnversion' or no SVN data detected
echo const char _openttd_revision[] = "norev000"; > rev.c
echo const int _revision_number = 0; >> rev.c
goto end
:end
cd os\os2
del svnver.tmp > nul 2> nul
rem end

View File

@@ -1,3 +0,0 @@
/* rev.c part #1 for OS/2 - ensure no newline at end of file! */
const char _openttd_revision[] = "r

View File

@@ -1,4 +0,0 @@
";
const int _revision_number = 0;
/* rev.c part 2 for OS/2 - ensure no newline at start of file! */

View File

@@ -1,7 +0,0 @@
add_files(
getaddrinfo.c
getaddrinfo.h
getnameinfo.c
getnameinfo.h
CONDITION OPTION_OS2
)

View File

@@ -1,299 +0,0 @@
/*
* This file is part of libESMTP, a library for submission of RFC 2822
* formatted electronic mail messages using the SMTP protocol described
* in RFC 2821.
*
* Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* An emulation of the RFC 2553 / Posix getaddrinfo resolver interface.
*/
#if !HAVE_GETADDRINFO
/* Need to turn off Posix features in glibc to build this */
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include "getaddrinfo.h"
//#include "compat/inet_pton.h"
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
static struct addrinfo *
dup_addrinfo (struct addrinfo *info, void *addr, size_t addrlen) {
struct addrinfo *ret;
ret = malloc (sizeof (struct addrinfo));
if (ret == NULL)
return NULL;
memcpy (ret, info, sizeof (struct addrinfo));
ret->ai_addr = malloc (addrlen);
if (ret->ai_addr == NULL) {
free (ret);
return NULL;
}
memcpy (ret->ai_addr, addr, addrlen);
ret->ai_addrlen = addrlen;
return ret;
}
int
getaddrinfo (const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res)
{
struct hostent *hp;
struct servent *servent;
const char *socktype;
int port;
struct addrinfo hint, result;
struct addrinfo *ai, *sai, *eai;
char **addrs;
if (servname == NULL && nodename == NULL)
return EAI_NONAME;
memset (&result, 0, sizeof result);
/* default for hints */
if (hints == NULL) {
memset (&hint, 0, sizeof hint);
hint.ai_family = PF_UNSPEC;
hints = &hint;
}
if (servname == NULL)
port = 0;
else {
/* check for tcp or udp sockets only */
if (hints->ai_socktype == SOCK_STREAM)
socktype = "tcp";
else if (hints->ai_socktype == SOCK_DGRAM)
socktype = "udp";
else
return EAI_SERVICE;
result.ai_socktype = hints->ai_socktype;
/* Note: maintain port in host byte order to make debugging easier */
if (isdigit (*servname))
port = strtol (servname, NULL, 10);
else if ((servent = getservbyname (servname, socktype)) != NULL)
port = ntohs (servent->s_port);
else
return EAI_NONAME;
}
/* if nodename == NULL refer to the local host for a client or any
for a server */
if (nodename == NULL) {
struct sockaddr_in sin;
/* check protocol family is PF_UNSPEC or PF_INET - could try harder
for IPv6 but that's more code than I'm prepared to write */
if (hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET)
result.ai_family = AF_INET;
else
return EAI_FAMILY;
sin.sin_family = result.ai_family;
sin.sin_port = htons (port);
if (hints->ai_flags & AI_PASSIVE)
sin.sin_addr.s_addr = htonl (INADDR_ANY);
else
sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
/* Duplicate result and addr and return */
*res = dup_addrinfo (&result, &sin, sizeof sin);
return (*res == NULL) ? EAI_MEMORY : 0;
}
/* If AI_NUMERIC is specified, use inet_pton to translate numbers and
dots notation. */
if (hints->ai_flags & AI_NUMERICHOST) {
struct sockaddr_in sin;
/* check protocol family is PF_UNSPEC or PF_INET */
if (hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET)
result.ai_family = AF_INET;
else
return EAI_FAMILY;
sin.sin_family = result.ai_family;
sin.sin_port = htons (port);
if (inet_pton(result.ai_family, nodename, &sin.sin_addr)==0)
return EAI_NONAME;
sin.sin_addr.s_addr = inet_addr (nodename);
/* Duplicate result and addr and return */
*res = dup_addrinfo (&result, &sin, sizeof sin);
return (*res == NULL) ? EAI_MEMORY : 0;
}
#if HAVE_H_ERRNO
h_errno = 0;
#endif
errno = 0;
hp = gethostbyname(nodename);
if (hp == NULL) {
#ifdef EAI_SYSTEM
if (errno != 0) {
return EAI_SYSTEM;
}
#endif
switch (h_errno) {
case HOST_NOT_FOUND:
return EAI_NODATA;
case NO_DATA:
return EAI_NODATA;
#if defined(NO_ADDRESS) && NO_ADDRESS != NO_DATA
case NO_ADDRESS:
return EAI_NODATA;
#endif
case NO_RECOVERY:
return EAI_FAIL;
case TRY_AGAIN:
return EAI_AGAIN;
default:
return EAI_FAIL;
}
return EAI_FAIL;
}
/* Check that the address family is acceptable.
*/
switch (hp->h_addrtype) {
case AF_INET:
if (!(hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET))
return EAI_FAMILY;
break;
#ifndef __OS2__
case AF_INET6:
if (!(hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET6))
return EAI_FAMILY;
break;
#endif
default:
return EAI_FAMILY;
}
/* For each element pointed to by hp, create an element in the
result linked list. */
sai = eai = NULL;
for (addrs = hp->h_addr_list; *addrs != NULL; addrs++) {
struct sockaddr sa;
size_t addrlen;
if (hp->h_length < 1)
continue;
sa.sa_family = hp->h_addrtype;
switch (hp->h_addrtype) {
case AF_INET:
((struct sockaddr_in *) &sa)->sin_port = htons (port);
memcpy (&((struct sockaddr_in *) &sa)->sin_addr,
*addrs, hp->h_length);
addrlen = sizeof (struct sockaddr_in);
break;
#ifndef __OS2__
case AF_INET6:
#if SIN6_LEN
((struct sockaddr_in6 *) &sa)->sin6_len = hp->h_length;
#endif
((struct sockaddr_in6 *) &sa)->sin6_port = htons (port);
memcpy (&((struct sockaddr_in6 *) &sa)->sin6_addr,
*addrs, hp->h_length);
addrlen = sizeof (struct sockaddr_in6);
break;
#endif
default:
continue;
}
result.ai_family = hp->h_addrtype;
ai = dup_addrinfo (&result, &sa, addrlen);
if (ai == NULL) {
freeaddrinfo (sai);
return EAI_MEMORY;
}
if (sai == NULL)
sai = ai;
else
eai->ai_next = ai;
eai = ai;
}
if (sai == NULL) {
return EAI_NODATA;
}
if (hints->ai_flags & AI_CANONNAME) {
sai->ai_canonname = malloc (strlen (hp->h_name) + 1);
if (sai->ai_canonname == NULL) {
freeaddrinfo (sai);
return EAI_MEMORY;
}
strcpy (sai->ai_canonname, hp->h_name);
}
*res = sai;
return 0;
}
void
freeaddrinfo (struct addrinfo *ai)
{
struct addrinfo *next;
while (ai != NULL) {
next = ai->ai_next;
if (ai->ai_canonname != NULL)
free (ai->ai_canonname);
if (ai->ai_addr != NULL)
free (ai->ai_addr);
free (ai);
ai = next;
}
}
const char *
gai_strerror (int ecode)
{
static const char *eai_descr[] = {
"no error",
"address family for nodename not supported", /* EAI_ADDRFAMILY */
"temporary failure in name resolution", /* EAI_AGAIN */
"invalid value for ai_flags", /* EAI_BADFLAGS */
"non-recoverable failure in name resolution", /* EAI_FAIL */
"ai_family not supported", /* EAI_FAMILY */
"memory allocation failure", /* EAI_MEMORY */
"no address associated with nodename", /* EAI_NODATA */
"nodename nor servname provided, or not known", /* EAI_NONAME */
"servname not supported for ai_socktype", /* EAI_SERVICE */
"ai_socktype not supported", /* EAI_SOCKTYPE */
"system error returned in errno", /* EAI_SYSTEM */
"argument buffer overflow", /* EAI_OVERFLOW */
};
if (ecode < 0 || ecode > (int) (sizeof eai_descr/ sizeof eai_descr[0]))
return "unknown error";
return eai_descr[ecode];
}
#endif /* HAVE_GETADDRINFO */

View File

@@ -1,101 +0,0 @@
#ifndef _getaddrinfo_h
#define _getaddrinfo_h
/*
* Shamelessly duplicated from the fetchmail public sources
* for use by the Squid Project under GNU Public License.
*
* Update/Maintenance History:
*
* 15-Aug-2007 : Copied from fetchmail 6.3.8
* - added protection around libray headers
*
* 16-Aug-2007 : Altered configure checks
* Un-hacked slightly to use system gethostbyname()
*
* Original License and code follows.
*/
/*
* This file is part of libESMTP, a library for submission of RFC 2822
* formatted electronic mail messages using the SMTP protocol described
* in RFC 2821.
*
* Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Structure and prototypes taken from RFC 2553 */
/* SG 23/09/2007:
On Windows the following definitions are already available, may be that
this could be needed on some other platform */
typedef int socklen_t;
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
socklen_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for nodename */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
/* Supposed to be defined in <netdb.h> */
#define AI_ADDRCONFIG 0
#define AI_PASSIVE 1 /* Socket address is intended for `bind'. */
#define AI_CANONNAME 2 /* Request for canonical name. */
#define AI_NUMERICHOST 4 /* Don't use name resolution. */
/* Supposed to be defined in <netdb.h> */
#define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
#define EAI_AGAIN 2 /* temporary failure in name resolution */
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /* ai_family not supported */
#define EAI_MEMORY 6 /* memory allocation failure */
#define EAI_NODATA 7 /* no address associated with nodename */
#define EAI_NONAME 8 /* nodename nor servname provided, or not known */
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
#ifndef EAI_SYSTEM
/* Not defined on mingw32. */
#define EAI_SYSTEM 11 /* System error returned in `errno'. */
#endif
#ifndef EAI_OVERFLOW
/* Not defined on mingw32. */
#define EAI_OVERFLOW 12 /* Argument buffer overflow. */
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* RFC 2553 / Posix resolver */
int getaddrinfo (const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res);
/* Free addrinfo structure and associated storage */
void freeaddrinfo (struct addrinfo *ai);
/* Convert error return from getaddrinfo() to string */
const char *gai_strerror (int code);
#ifdef __cplusplus
}
#endif
#endif /* _getaddrinfo_h */

View File

@@ -1,367 +0,0 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Issues to be discussed:
* - RFC2553 says that we should raise error on short buffer. X/Open says
* we need to truncate the result. We obey RFC2553 (and X/Open should be
* modified). ipngwg rough consensus seems to follow RFC2553. RFC3493 says
* nothing about it, but defines a new error code EAI_OVERFLOW which seems
* to be intended the code for this case.
* - What is "local" in NI_NOFQDN? (see comments in the code)
* - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
* - (KAME extension) always attach textual scopeid (fe80::1%lo0), if
* sin6_scope_id is filled - standardization status?
* - what should we do if we should do getservbyport("sctp")?
*/
/*
* Considerations about thread-safeness
* The code in this file is thread-safe, and so the thread-safeness of
* getnameinfo() depends on the property of backend functions.
* - getservbyport() is not thread safe for most systems we are targeting.
* - getipnodebyaddr() is thread safe. However, many resolver libraries
* used in the function are not thread safe.
* - gethostbyaddr() is usually not thread safe.
*/
#if !HAVE_GETNAMEINFO
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <stddef.h>
#include <errno.h>
#include <inttypes.h>
#include "getaddrinfo.h"
#include "getnameinfo.h"
static const struct afd {
int a_af;
int a_addrlen;
int a_socklen;
int a_off;
int a_portoff;
} afdl [] = {
#if INET6
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr),
offsetof(struct sockaddr_in6, sin6_port)},
#endif
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
offsetof(struct sockaddr_in, sin_addr),
offsetof(struct sockaddr_in, sin_port)},
{0, 0, 0, 0, 0},
};
#if INET6
static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
size_t, int));
static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int));
#endif
int
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
const struct sockaddr *sa;
socklen_t salen;
char *host;
size_t hostlen;
char *serv;
size_t servlen;
int flags;
{
const struct afd *afd;
struct servent *sp;
struct hostent *hp;
unsigned short port;
int family, i;
const char *addr;
uint32_t v4a;
char numserv[512];
if (sa == NULL)
return EAI_FAIL;
#if HAVE_SA_LEN /*XXX*/
if (sa->sa_len != salen)
return EAI_FAIL;
#endif
family = sa->sa_family;
for (i = 0; afdl[i].a_af; i++)
if (afdl[i].a_af == family) {
afd = &afdl[i];
goto found;
}
return EAI_FAMILY;
found:
if (salen != afd->a_socklen)
return EAI_FAIL;
/* network byte order */
memcpy(&port, (const char *)sa + afd->a_portoff, sizeof(port));
addr = (const char *)sa + afd->a_off;
if (serv == NULL || servlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC3493 says that serv == NULL OR servlen == 0
* means that the caller does not want the result.
*/
} else {
if (flags & NI_NUMERICSERV)
sp = NULL;
else {
sp = getservbyport(port,
(flags & NI_DGRAM) ? "udp" : "tcp");
}
if (sp) {
if (strlen(sp->s_name) + 1 > servlen)
return EAI_OVERFLOW;
strncpy(serv, sp->s_name, servlen);
} else {
snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
if (strlen(numserv) + 1 > servlen)
return EAI_OVERFLOW;
strncpy(serv, numserv, servlen);
}
}
switch (sa->sa_family) {
case AF_INET:
v4a = (uint32_t)
ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST;
v4a >>= IN_CLASSA_NSHIFT;
if (v4a == 0)
flags |= NI_NUMERICHOST;
break;
#if INET6
case AF_INET6: {
const struct sockaddr_in6 *sin6;
sin6 = (const struct sockaddr_in6 *)sa;
switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
;
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
;
else
flags |= NI_NUMERICHOST;
break;
default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
break;
}
}
break;
#endif
}
if (host == NULL || hostlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC3493 says that host == NULL or hostlen == 0
* means that the caller does not want the result.
*/
} else if (flags & NI_NUMERICHOST) {
/* NUMERICHOST and NAMEREQD conflicts with each other */
if (flags & NI_NAMEREQD)
return EAI_NONAME;
goto numeric;
} else {
#if USE_GETIPNODEBY
int h_error = 0;
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
#else
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
#if 0 // getnameinfo.c:161:9: error: variable 'h_error' set but not used
#if HAVE_H_ERRNO
h_error = h_errno;
#else
h_error = EINVAL;
#endif
#endif /* 0 */
#endif
if (hp) {
#if 0
if (flags & NI_NOFQDN) {
/*
* According to RFC3493 section 6.2, NI_NOFQDN
* means "node name portion of the FQDN shall
* be returned for local hosts." The following
* code tries to implement it by returning the
* first label (the part before the first
* period) of the FQDN. However, it is not
* clear if this always makes sense, since the
* given address may be outside of "local
* hosts." Due to the unclear description, we
* disable the code in this implementation.
*/
char *p;
p = strchr(hp->h_name, '.');
if (p)
*p = '\0';
}
#endif
if (strlen(hp->h_name) + 1 > hostlen) {
#if USE_GETIPNODEBY
freehostent(hp);
#endif
return EAI_OVERFLOW;
}
strncpy(host, hp->h_name, hostlen);
#if USE_GETIPNODEBY
freehostent(hp);
#endif
} else {
if (flags & NI_NAMEREQD)
return EAI_NONAME;
numeric:
switch (afd->a_af) {
#if INET6
case AF_INET6: {
int error;
if ((error = ip6_parsenumeric(sa, addr, host,
hostlen,
flags)) != 0)
return(error);
break;
}
#endif
default:
if (inet_ntop(afd->a_af, addr, host,
hostlen) == NULL)
return EAI_SYSTEM;
break;
}
}
}
return(0);
}
#if INET6
static int
ip6_parsenumeric(sa, addr, host, hostlen, flags)
const struct sockaddr *sa;
const char *addr;
char *host;
size_t hostlen;
int flags;
{
int numaddrlen;
char numaddr[512];
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
return EAI_SYSTEM;
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return EAI_OVERFLOW;
strncpy(host, numaddr, hostlen);
if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
char zonebuf[SQUIDHOSTNAMELEN];
int zonelen;
zonelen = ip6_sa2str(
(const struct sockaddr_in6 *)(const void *)sa,
zonebuf, sizeof(zonebuf), flags);
if (zonelen < 0)
return EAI_OVERFLOW;
if (zonelen + 1 + numaddrlen + 1 > hostlen)
return EAI_OVERFLOW;
/* construct <numeric-addr><delim><zoneid> */
memcpy(host + numaddrlen + 1, zonebuf,
(size_t)zonelen);
host[numaddrlen] = SCOPE_DELIMITER;
host[numaddrlen + 1 + zonelen] = '\0';
}
return 0;
}
/* ARGSUSED */
static int
ip6_sa2str(sa6, buf, bufsiz, flags)
const struct sockaddr_in6 *sa6;
char *buf;
size_t bufsiz;
int flags;
{
unsigned int ifindex;
const struct in6_addr *a6;
int n;
ifindex = (unsigned int)sa6->sin6_scope_id;
a6 = &sa6->sin6_addr;
#if NI_NUMERICSCOPE
if ((flags & NI_NUMERICSCOPE) != 0) {
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if (n < 0 || n >= bufsiz)
return -1;
else
return n;
}
#endif
/* if_indextoname() does not take buffer size. not a good api... */
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) ||
IN6_IS_ADDR_MC_NODELOCAL(a6)) && bufsiz >= IF_NAMESIZE) {
char *p = if_indextoname(ifindex, buf);
if (p)
return (strlen(p));
}
/* last resort */
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if (n < 0 || n >= bufsiz)
return -1;
else
return n;
}
#endif /* INET6 */
#endif

View File

@@ -1,29 +0,0 @@
#ifndef _getnameinfo_h
#define _getnameinfo_h
/*
* Reconstructed from KAME getnameinfo.c (in lib/)
*/
/* getnameinfo flags */
#define NI_NOFQDN 0x0001
#define NI_NUMERICHOST 0x0002 /* return numeric form of address */
#define NI_NAMEREQD 0x0004 /* request DNS name */
#define NI_NUMERICSERV 0x0008
#define NI_DGRAM 0x0010
#ifdef __cplusplus
extern "C" {
#endif
/* RFC 2553 / Posix resolver */
int getnameinfo(const struct sockaddr *sa,
socklen_t salen,
char *host,
size_t hostlen,
char *serv,
size_t servlen,
int flags );
#ifdef __cplusplus
}
#endif
#endif /* _getnameinfo_h */

View File

@@ -9,7 +9,7 @@ namespace citymania {
// Returns 8 higher bits of s-bit integer x // Returns 8 higher bits of s-bit integer x
#define FIRST8(x, s) (((x) >> ((s) - 8)) & 0xFF) #define FIRST8(x, s) (((x) >> ((s) - 8)) & 0xFF)
void BitOStream::WriteBytes(uint32 value, int amount) void BitOStream::WriteBytes(uint32_t value, int amount)
{ {
do { do {
v = (v << 8) | FIRST8(value, amount << 3); v = (v << 8) | FIRST8(value, amount << 3);
@@ -17,7 +17,7 @@ void BitOStream::WriteBytes(uint32 value, int amount)
} while (--amount); } while (--amount);
} }
void BitOStream::WriteBytes64(uint64 value, int amount) void BitOStream::WriteBytes64(uint64_t value, int amount)
{ {
do { do {
v = (v << 8) | FIRST8(value, amount << 3); v = (v << 8) | FIRST8(value, amount << 3);
@@ -56,9 +56,9 @@ uint BitOStream::GetByteSize() const
BitIStreamUnexpectedEnd _bit_i_stream_unexpected_end; BitIStreamUnexpectedEnd _bit_i_stream_unexpected_end;
uint32 BitIStream::ReadBytes(uint amount) uint32_t BitIStream::ReadBytes(uint amount)
{ {
uint32 res = 0; uint32_t res = 0;
while (amount--) { while (amount--) {
if (i >= f.size()) { if (i >= f.size()) {
throw _bit_i_stream_unexpected_end; throw _bit_i_stream_unexpected_end;
@@ -68,9 +68,9 @@ uint32 BitIStream::ReadBytes(uint amount)
return res; return res;
} }
uint64 BitIStream::ReadBytes64(uint amount) uint64_t BitIStream::ReadBytes64(uint amount)
{ {
uint64 res = 0; uint64_t res = 0;
while (amount--) { while (amount--) {
if (i >= f.size()) { if (i >= f.size()) {
throw _bit_i_stream_unexpected_end; throw _bit_i_stream_unexpected_end;

View File

@@ -7,20 +7,20 @@
namespace citymania { namespace citymania {
typedef std::vector<uint8> u8vector; typedef std::vector<uint8_t> u8vector;
class BitOStream { class BitOStream {
protected: protected:
u8vector f; u8vector f;
uint32 c; uint32_t c;
uint32 v; uint32_t v;
public: public:
BitOStream(): c(0), v(0) {} BitOStream(): c(0), v(0) {}
virtual ~BitOStream(){} virtual ~BitOStream(){}
void Reserve(int bytes); void Reserve(int bytes);
void WriteBytes(uint32 value, int amount); void WriteBytes(uint32_t value, int amount);
void WriteBytes64(uint64 value, int amount); void WriteBytes64(uint64_t value, int amount);
void WriteMoney(Money value); void WriteMoney(Money value);
const u8vector &GetVector(); const u8vector &GetVector();
uint GetByteSize() const; uint GetByteSize() const;
@@ -35,12 +35,12 @@ class BitIStreamUnexpectedEnd: public std::exception {
class BitIStream { class BitIStream {
protected: protected:
u8vector &f; u8vector &f;
uint32 i; uint32_t i;
public: public:
BitIStream(u8vector &data): f(data), i(0) {} BitIStream(u8vector &data): f(data), i(0) {}
virtual ~BitIStream(){} virtual ~BitIStream(){}
uint32 ReadBytes(uint amount); uint32_t ReadBytes(uint amount);
uint64 ReadBytes64(uint amount); uint64_t ReadBytes64(uint amount);
Money ReadMoney(); Money ReadMoney();
}; };

View File

@@ -29,7 +29,7 @@ struct TownBuilt {
struct TownGrowthSucceeded { struct TownGrowthSucceeded {
Town *town; Town *town;
TileIndex tile; TileIndex tile;
uint32 prev_houses; uint32_t prev_houses;
}; };
struct TownGrowthFailed { struct TownGrowthFailed {
@@ -116,7 +116,7 @@ struct CompanyBalanceChanged {
Money delta; Money delta;
}; };
enum class Slot : uint8 { enum class Slot : uint8_t {
GOAL = 10, GOAL = 10,
CONTROLLER = 20, CONTROLLER = 20,
GAME = 30, GAME = 30,

View File

@@ -6,6 +6,7 @@
#include "../gfx_func.h" #include "../gfx_func.h"
#include "../gfx_type.h" #include "../gfx_type.h"
#include "../engine_base.h" #include "../engine_base.h"
#include "../palette_func.h" // CM _colour_gradient
#include "../spritecache.h" #include "../spritecache.h"
#include "../strings_func.h" #include "../strings_func.h"
#include "../strings_type.h" #include "../strings_type.h"
@@ -22,7 +23,7 @@
namespace citymania { namespace citymania {
extern SpriteID (*GetDefaultTrainSprite)(uint8, Direction); // train_cmd.cpp extern SpriteID (*GetDefaultTrainSprite)(uint8_t, Direction); // train_cmd.cpp
namespace data_export { namespace data_export {
@@ -70,7 +71,7 @@ public:
f << val; f << val;
} }
void value(uint64 val) { void value(uint64_t val) {
f << val; f << val;
} }
@@ -97,9 +98,8 @@ public:
} }
void ks(const char *k, StringID s) { void ks(const char *k, StringID s) {
GetString(buffer, s, lastof(buffer));
key(k); key(k);
value(buffer); value(GetString(s));
} }
void begin_dict_with_key(const char *k) { void begin_dict_with_key(const char *k) {
@@ -149,8 +149,8 @@ void WriteHouseSpecInfo(JsonWriter &j) {
j.begin_dict(); j.begin_dict();
JKV(j, cs->initial_payment); JKV(j, cs->initial_payment);
j.kv("id", cs->bitnum); j.kv("id", cs->bitnum);
j.kv("transit_days_1", cs->transit_days[0]); j.kv("transit_periods_1", cs->transit_periods[0]);
j.kv("transit_days_2", cs->transit_days[1]); j.kv("transit_periods_2", cs->transit_periods[1]);
JKV(j, cs->weight); JKV(j, cs->weight);
JKV(j, cs->multiplier); JKV(j, cs->multiplier);
JKV(j, cs->is_freight); JKV(j, cs->is_freight);
@@ -164,7 +164,7 @@ void WriteHouseSpecInfo(JsonWriter &j) {
j.ks("abbrev", cs->abbrev); j.ks("abbrev", cs->abbrev);
for (uint i = 0; i < sizeof(cs->label); i++) { for (uint i = 0; i < sizeof(cs->label); i++) {
cargo_label[i] = GB(cs->label, (uint8)(sizeof(cs->label) - i - 1) * 8, 8); cargo_label[i] = GB(cs->label, (uint8_t)(sizeof(cs->label) - i - 1) * 8, 8);
} }
cargo_label[sizeof(cs->label)] = '\0'; cargo_label[sizeof(cs->label)] = '\0';
JKV(j, cs->label); JKV(j, cs->label);
@@ -203,7 +203,7 @@ void WritePaletteInfo(JsonWriter &j) {
j.f << "]"; j.f << "]";
} }
j.end_list(); j.end_list();
const byte *remap = GetNonSprite(GB(PALETTE_TO_RED, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1; const byte *remap = GetNonSprite(GB(PALETTE_TO_RED, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
} }
void WriteEngineInfo(JsonWriter &j) { void WriteEngineInfo(JsonWriter &j) {
@@ -221,9 +221,9 @@ void WriteEngineInfo(JsonWriter &j) {
JKV(j, e->info.cargo_type); JKV(j, e->info.cargo_type);
JKV(j, e->info.cargo_age_period); JKV(j, e->info.cargo_age_period);
JKV(j, e->info.climates); JKV(j, e->info.climates);
JKV(j, e->info.base_intro); JKV(j, e->info.base_intro.base());
JKV(j, e->info.lifelength); JKV(j, e->info.lifelength.base());
JKV(j, e->info.base_life); JKV(j, e->info.base_life.base());
JKV(j, e->info.refit_mask); JKV(j, e->info.refit_mask);
JKV(j, e->info.refit_cost); JKV(j, e->info.refit_cost);
JKV(j, e->info.load_amount); JKV(j, e->info.load_amount);

View File

@@ -99,7 +99,7 @@ Game::Game() {
if (this->towns_growth_tiles_last_month[tile] < state) this->towns_growth_tiles_last_month[tile] = state; if (this->towns_growth_tiles_last_month[tile] < state) this->towns_growth_tiles_last_month[tile] = state;
} }
} }
for (TileIndex t = 0; t < MapSize(); t++) { for (auto t : Map::Iterate()) {
if (!IsTileType(t, MP_HOUSE)) continue; if (!IsTileType(t, MP_HOUSE)) continue;
Town *town = Town::GetByTile(t); Town *town = Town::GetByTile(t);
if (!IsHouseCompleted(t)) if (!IsHouseCompleted(t))

View File

@@ -1,7 +1,6 @@
#include "../stdafx.h" #include "../stdafx.h"
#include "../company_base.h" #include "../company_base.h"
#include "../date_func.h"
#include "../debug.h" #include "../debug.h"
#include "../saveload/compat/storage_sl_compat.h" #include "../saveload/compat/storage_sl_compat.h"
#include "../saveload/saveload.h" #include "../saveload/saveload.h"

View File

@@ -12,17 +12,17 @@ namespace citymania {
class CBRequirement { class CBRequirement {
public: public:
CargoID cargo_id; CargoID cargo_id;
uint32 from; uint32_t from;
uint32 amount; uint32_t amount;
uint8 decay; uint8_t decay;
uint8 index; uint8_t index;
std::string name; std::string name;
bool has_storage; bool has_storage;
static CBRequirement Parse(const char *name, const char *value, uint8 index); static CBRequirement Parse(const char *name, const char *value, uint8_t index);
CBRequirement(CargoID cargo_id, uint32 from, uint32 amount, uint8 decay, CBRequirement(CargoID cargo_id, uint32_t from, uint32_t amount, uint8_t decay,
uint8 index, std::string name) uint8_t index, std::string name)
:cargo_id{cargo_id}, from{from}, amount{amount}, decay{decay}, :cargo_id{cargo_id}, from{from}, amount{amount}, decay{decay},
index{index}, name{name}, has_storage{decay < 100} {} index{index}, name{name}, has_storage{decay < 100} {}
}; };
@@ -34,19 +34,19 @@ struct EconomySettings {
}; };
struct LimitsSettings { struct LimitsSettings {
uint16 max_airports; ///< maximum number of airports per company, 0=unlimited uint16_t max_airports; ///< maximum number of airports per company, 0=unlimited
bool disable_canals; bool disable_canals;
uint16 min_distance_between_docks; ///< docks can be build only x tiles apart another, 0=disable check uint16_t min_distance_between_docks; ///< docks can be build only x tiles apart another, 0=disable check
}; };
struct CBSettings { struct CBSettings {
uint8 requirements_type; // 0 - regular 1 - income-based requirements (new cb only) uint8_t requirements_type; // 0 - regular 1 - income-based requirements (new cb only)
std::vector<CBRequirement> requirements; std::vector<CBRequirement> requirements;
uint16 acceptance_range; // How far can station be to count towards requiremnts uint16_t acceptance_range; // How far can station be to count towards requiremnts
uint8 storage_size; // cargo storage multiplier (x * monthly requirements) uint8_t storage_size; // cargo storage multiplier (x * monthly requirements)
uint8 town_protection_range; // Claimed town protection range (square from centre), overlaped with tz0 uint8_t town_protection_range; // Claimed town protection range (square from centre), overlaped with tz0
uint16 claim_max_houses; // Max amount of houses claimable town can have uint16_t claim_max_houses; // Max amount of houses claimable town can have
bool smooth_growth_rate; // Calculate growth rate precisely instead of rounding to 50 houses and allow going below 70 ticks (default max) bool smooth_growth_rate; // Calculate growth rate precisely instead of rounding to 50 houses and allow going below 70 ticks (default max)
bool allow_negative_growth; // Make town shrink (with the same speed as growth) if requirements aren't satisfied bool allow_negative_growth; // Make town shrink (with the same speed as growth) if requirements aren't satisfied
}; };
@@ -58,11 +58,11 @@ struct Settings {
GameType game_type; // GameType GameType game_type; // GameType
ControllerType controller_type; // ControllerType ControllerType controller_type; // ControllerType
uint8 max_players_in_company; uint8_t max_players_in_company;
uint16 destroyed_houses_per_month; // max amount of houses a company can destroy per month uint16_t destroyed_houses_per_month; // max amount of houses a company can destroy per month
uint16 game_length_years; // game length in years(0 = disabled) uint16_t game_length_years; // game length in years(0 = disabled)
bool protect_funded_industries; bool protect_funded_industries;
uint16 same_depot_sell_years; // can only sell vehicles in the same place (20 tiles radius) for first x yearss of its lifetime (0 = disabled) uint16_t same_depot_sell_years; // can only sell vehicles in the same place (20 tiles radius) for first x yearss of its lifetime (0 = disabled)
}; };
}; // namespace citymania }; // namespace citymania

View File

@@ -44,7 +44,7 @@ template<class T, class... Args>
make_up(Args&&...) = delete; make_up(Args&&...) = delete;
enum class GameType: uint8 { enum class GameType: uint8_t {
GENERIC = 0, GENERIC = 0,
GOAL = 1, GOAL = 1,
MULTIGOAL = 2, MULTIGOAL = 2,
@@ -55,7 +55,7 @@ enum class GameType: uint8 {
_NOT_A_GAME_TYPE_TOWN_DEFENCE = 6, _NOT_A_GAME_TYPE_TOWN_DEFENCE = 6,
}; };
enum class ControllerType: uint8 { enum class ControllerType: uint8_t {
GENERIC = 0, GENERIC = 0,
_NOT_A_CONTROLLER_GOAL = 1, _NOT_A_CONTROLLER_GOAL = 1,
_NOT_A_CONTROLLER_MULTIGOAL = 2, _NOT_A_CONTROLLER_MULTIGOAL = 2,

View File

@@ -5,7 +5,7 @@
namespace citymania { namespace citymania {
enum class TownGrowthTileState : uint8 { enum class TownGrowthTileState : uint8_t {
NONE = 0, NONE = 0,
RH_REMOVED, RH_REMOVED,
NEW_HOUSE, NEW_HOUSE,
@@ -22,21 +22,21 @@ namespace ext {
class Town { class Town {
public: public:
bool growing_by_chance = false; ///< whether town is growing due to 1/12 chance bool growing_by_chance = false; ///< whether town is growing due to 1/12 chance
uint32 real_population = 0; ///< population including unfinished houses uint32_t real_population = 0; ///< population including unfinished houses
uint32 hs_total = 0; ///< number of skipped house buildings (HS) in total uint32_t hs_total = 0; ///< number of skipped house buildings (HS) in total
uint16 hs_this_month = 0; ///< number of skipped house buildings (HS) during the current month uint16_t hs_this_month = 0; ///< number of skipped house buildings (HS) during the current month
uint16 hs_last_month = 0; ///< number of skipped house buildings (HS) during last month uint16_t hs_last_month = 0; ///< number of skipped house buildings (HS) during last month
uint32 cs_total = 0; ///< number of skipped growth cycles (CS) in total uint32_t cs_total = 0; ///< number of skipped growth cycles (CS) in total
uint16 cs_this_month = 0; ///< number of skipped growth cycles (CS) during the current month uint16_t cs_this_month = 0; ///< number of skipped growth cycles (CS) during the current month
uint16 cs_last_month = 0; ///< number of skipped growth cycles (CS) during last month uint16_t cs_last_month = 0; ///< number of skipped growth cycles (CS) during last month
uint32 hr_total = 0; ///< number of houses removed by the server (HR) in total uint32_t hr_total = 0; ///< number of houses removed by the server (HR) in total
uint16 hr_this_month = 0; ///< number of houses removed by the server (HR) during the current month uint16_t hr_this_month = 0; ///< number of houses removed by the server (HR) during the current month
uint16 hr_last_month = 0; ///< number of houses removed by the server (HR) during last month uint16_t hr_last_month = 0; ///< number of houses removed by the server (HR) during last month
uint16 houses_constructing = 0; ///< number of houses currently being built uint16_t houses_constructing = 0; ///< number of houses currently being built
uint16 houses_reconstructed_this_month = 0; ///< number of houses rebuilt this month uint16_t houses_reconstructed_this_month = 0; ///< number of houses rebuilt this month
uint16 houses_reconstructed_last_month = 0; ///< number of houses rebuild last month uint16_t houses_reconstructed_last_month = 0; ///< number of houses rebuild last month
uint16 houses_demolished_this_month = 0; ///< number of houses demolished this month uint16_t houses_demolished_this_month = 0; ///< number of houses demolished this month
uint16 houses_demolished_last_month = 0; ///< number of houses demolished last month uint16_t houses_demolished_last_month = 0; ///< number of houses demolished last month
TownsGrowthTilesIndex growth_tiles_last_month; TownsGrowthTilesIndex growth_tiles_last_month;
TownsGrowthTilesIndex growth_tiles; TownsGrowthTilesIndex growth_tiles;

View File

@@ -1,35 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file date_func.h Functions related to dates. */
#ifndef DATE_FUNC_H
#define DATE_FUNC_H
#include "date_type.h"
extern Year _cur_year;
extern Month _cur_month;
extern Date _date;
extern DateFract _date_fract;
extern uint64 _tick_counter;
void SetDate(Date date, DateFract fract);
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
Date ConvertYMDToDate(Year year, Month month, Day day);
/**
* Checks whether the given year is a leap year or not.
* @param yr The year to check.
* @return True if \c yr is a leap year, otherwise false.
*/
static inline bool IsLeapYear(Year yr)
{
return yr % 4 == 0 && (yr % 100 != 0 || yr % 400 == 0);
}
#endif /* DATE_FUNC_H */

View File

@@ -912,7 +912,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
std::string client_name = p->Recv_string(NETWORK_CLIENT_NAME_LENGTH); std::string client_name = p->Recv_string(NETWORK_CLIENT_NAME_LENGTH);
CompanyID playas = (Owner)p->Recv_uint8(); CompanyID playas = (Owner)p->Recv_uint8();
p->Recv_uint8(); // former client_lang now 0 p->Recv_uint8(); // former client_lang now 0
uint8 savegame_formats = p->CanReadFromPacket(1, false) ? p->Recv_uint8() : 23u /* assume non-modded has everything but zstd */; uint8_t savegame_formats = p->CanReadFromPacket(1, false) ? p->Recv_uint8() : 23u /* assume non-modded has everything but zstd */;
if (this->HasClientQuit()) return NETWORK_RECV_STATUS_CLIENT_QUIT; if (this->HasClientQuit()) return NETWORK_RECV_STATUS_CLIENT_QUIT;

View File

@@ -1,36 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file G5_detector.cpp Detection for G5 machines (PowerPC). */
#include <mach/mach.h>
#include <mach/mach_host.h>
#include <mach/host_info.h>
#include <mach/machine.h>
#include <stdio.h>
#ifndef CPU_SUBTYPE_POWERPC_970
#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
#endif
/* this function is a lightly modified version of some code from Apple's developer homepage to detect G5 CPUs at runtime */
int main()
{
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
boolean_t is_G5;
infoCount = HOST_BASIC_INFO_COUNT;
host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount);
is_G5 = ((hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
(hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
if (is_G5)
printf("1");
}

View File

@@ -1,4 +0,0 @@
add_files(
os2.cpp
CONDITION OPTION_OS2
)

View File

@@ -1,214 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file os2.cpp OS2 related OS support. */
#include "../../stdafx.h"
#include "../../openttd.h"
#include "../../gui.h"
#include "../../fileio_func.h"
#include "../../fios.h"
#include "../../openttd.h"
#include "../../core/random_func.hpp"
#include "../../string_func.h"
#include "../../textbuf_gui.h"
#include "../../thread.h"
#include "table/strings.h"
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <time.h>
#ifndef __INNOTEK_LIBC__
# include <dos.h>
#endif
#include "../../safeguards.h"
#define INCL_WIN
#define INCL_WINCLIPBOARD
#include <os2.h>
#ifndef __INNOTEK_LIBC__
# include <i86.h>
#endif
bool FiosIsRoot(const char *file)
{
return file[3] == '\0';
}
void FiosGetDrives(FileList &file_list)
{
uint disk, disk2, save, total;
#ifndef __INNOTEK_LIBC__
_dos_getdrive(&save); // save original drive
#else
save = _getdrive(); // save original drive
char wd[MAX_PATH];
getcwd(wd, MAX_PATH);
total = 'z';
#endif
/* get an available drive letter */
#ifndef __INNOTEK_LIBC__
for (disk = 1;; disk++) {
_dos_setdrive(disk, &total);
#else
for (disk = 'A';; disk++) {
_chdrive(disk);
#endif
if (disk >= total) break;
#ifndef __INNOTEK_LIBC__
_dos_getdrive(&disk2);
#else
disk2 = _getdrive();
#endif
if (disk == disk2) {
FiosItem *fios = file_list.Append();
fios->type = FIOS_TYPE_DRIVE;
fios->mtime = 0;
#ifndef __INNOTEK_LIBC__
snprintf(fios->name, lengthof(fios->name), "%c:", 'A' + disk - 1);
#else
snprintf(fios->name, lengthof(fios->name), "%c:", disk);
#endif
strecpy(fios->title, fios->name, lastof(fios->title));
}
}
/* Restore the original drive */
#ifndef __INNOTEK_LIBC__
_dos_setdrive(save, &total);
#else
chdir(wd);
#endif
}
bool FiosGetDiskFreeSpace(const char *path, uint64 *tot)
{
#ifndef __INNOTEK_LIBC__
struct diskfree_t free;
char drive = path[0] - 'A' + 1;
if (tot != nullptr && _getdiskfree(drive, &free) == 0) {
*tot = free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector;
return true;
}
return false;
#else
uint64 free = 0;
#ifdef HAS_STATVFS
{
struct statvfs s;
if (statvfs(path, &s) != 0) return false;
free = (uint64)s.f_frsize * s.f_bavail;
}
#endif
if (tot != nullptr) *tot = free;
return true;
#endif
}
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
{
char filename[MAX_PATH];
snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name);
return stat(filename, sb) == 0;
}
bool FiosIsHiddenFile(const struct dirent *ent)
{
return ent->d_name[0] == '.';
}
void ShowInfo(const char *str)
{
HAB hab;
HMQ hmq;
ULONG rc;
/* init PM env. */
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
/* display the box */
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)str, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION);
/* terminate PM env. */
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
}
void ShowOSErrorBox(const char *buf, bool system)
{
HAB hab;
HMQ hmq;
ULONG rc;
/* init PM env. */
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
/* display the box */
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)buf, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR);
/* terminate PM env. */
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
}
int CDECL main(int argc, char *argv[])
{
SetRandomSeed(time(nullptr));
/* Make sure our arguments contain only valid UTF-8 characters. */
for (int i = 0; i < argc; i++) StrMakeValidInPlace(argv[i]);
return openttd_main(argc, argv);
}
bool GetClipboardContents(char *buffer, const char *last)
{
/* XXX -- Currently no clipboard support implemented with GCC */
#ifndef __INNOTEK_LIBC__
HAB hab = 0;
if (WinOpenClipbrd(hab))
{
const char *text = (const char*)WinQueryClipbrdData(hab, CF_TEXT);
if (text != nullptr)
{
strecpy(buffer, text, last);
WinCloseClipbrd(hab);
return true;
}
WinCloseClipbrd(hab);
}
#endif
return false;
}
void OSOpenBrowser(const char *url)
{
// stub only
Debug(misc, 0, "Failed to open url: {}", url);
}
void SetCurrentThreadName(const char *)
{
}

View File

@@ -2823,7 +2823,7 @@ static_assert(lengthof(_saveload_formats) <= 8); // uint8 is used for the bitse
* @param client_formats Bitset of savegame formats available to the client (as returned by GetAvailableLoadFormats) * @param client_formats Bitset of savegame formats available to the client (as returned by GetAvailableLoadFormats)
* @return SavePreset that satisfies both server and client or std::nullopt * @return SavePreset that satisfies both server and client or std::nullopt
*/ */
std::optional<SavePreset> FindCompatibleSavePreset(const std::string &server_formats, uint8 client_formats) std::optional<SavePreset> FindCompatibleSavePreset(const std::string &server_formats, uint8_t client_formats)
{ {
std::istringstream iss(server_formats.empty() ? DEFAULT_NETWORK_SAVEGAME_COMPRESSION : server_formats); std::istringstream iss(server_formats.empty() ? DEFAULT_NETWORK_SAVEGAME_COMPRESSION : server_formats);
std::string preset_str; std::string preset_str;
@@ -2839,9 +2839,9 @@ std::optional<SavePreset> FindCompatibleSavePreset(const std::string &server_for
* Return the bitset of savegame formats that this game instance can load * Return the bitset of savegame formats that this game instance can load
* @return bitset of available savegame formats * @return bitset of available savegame formats
*/ */
uint8 GetAvailableLoadFormats() uint8_t GetAvailableLoadFormats()
{ {
uint8 res = 0; uint8_t res = 0;
for(auto &slf : _saveload_formats) { for(auto &slf : _saveload_formats) {
if (slf.init_load != nullptr) { if (slf.init_load != nullptr) {
res |= (1 << slf.id); res |= (1 << slf.id);

View File

@@ -412,7 +412,7 @@ enum SavegameType {
namespace citymania { namespace citymania {
enum class CompressionMethod : uint8 { enum class CompressionMethod : uint8_t {
None = 0u, None = 0u,
LZO = 1u, LZO = 1u,
Zlib = 2u, Zlib = 2u,
@@ -422,9 +422,9 @@ enum class CompressionMethod : uint8 {
/** The format for a reader/writer type of a savegame */ /** The format for a reader/writer type of a savegame */
struct SaveLoadFormat { struct SaveLoadFormat {
uint8 id; ///< unique integer id of this savegame format (olny used for networkking so is not guaranteed to be preserved between versions) uint8_t id; ///< unique integer id of this savegame format (olny used for networkking so is not guaranteed to be preserved between versions)
const char *name; ///< name of the compressor/decompressor (debug-only) const char *name; ///< name of the compressor/decompressor (debug-only)
uint32 tag; ///< the 4-letter tag by which it is identified in the savegame uint32_t tag; ///< the 4-letter tag by which it is identified in the savegame
LoadFilter *(*init_load)(LoadFilter *chain); ///< Constructor for the load filter. LoadFilter *(*init_load)(LoadFilter *chain); ///< Constructor for the load filter.
SaveFilter *(*init_write)(SaveFilter *chain, byte compression); ///< Constructor for the save filter. SaveFilter *(*init_write)(SaveFilter *chain, byte compression); ///< Constructor for the save filter.
@@ -441,8 +441,8 @@ struct SavePreset {
byte compression_level; ///< compression level to use byte compression_level; ///< compression level to use
}; };
std::optional<SavePreset> FindCompatibleSavePreset(const std::string &server_formats, uint8 client_format_flags); std::optional<SavePreset> FindCompatibleSavePreset(const std::string &server_formats, uint8_t client_format_flags);
uint8 GetAvailableLoadFormats(); uint8_t GetAvailableLoadFormats();
} // namespace citymania } // namespace citymania

View File

@@ -1744,7 +1744,7 @@ static bool GrowTownAtRoad(Town *t, TileIndex tile)
break; break;
} }
uint16 prev_houses = t->cache.num_houses; uint16_t prev_houses = t->cache.num_houses;
do { do {
RoadBits cur_rb = GetTownRoadBits(tile); // The RoadBits of the current tile RoadBits cur_rb = GetTownRoadBits(tile); // The RoadBits of the current tile

View File

@@ -1,80 +0,0 @@
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file walltime_func.h Functionality related to the time of the clock on your wall. */
#ifndef WALLTIME_FUNC_H
#define WALLTIME_FUNC_H
#include <ctime>
/** Helper for safely converting a std::time_t to a local time std::tm using localtime_s. */
struct LocalTimeToStruct {
static inline std::tm ToTimeStruct(std::time_t time_since_epoch)
{
std::tm time = {};
#ifdef _WIN32
/* Windows has swapped the parameters around for localtime_s. */
localtime_s(&time, &time_since_epoch);
#else
localtime_r(&time_since_epoch, &time);
#endif
return time;
}
};
/** Helper for safely converting a std::time_t to a UTC time std::tm using gmtime_s. */
struct UTCTimeToStruct {
static inline std::tm ToTimeStruct(std::time_t time_since_epoch)
{
std::tm time = {};
#ifdef _WIN32
/* Windows has swapped the parameters around for gmtime_s. */
gmtime_s(&time, &time_since_epoch);
#else
gmtime_r(&time_since_epoch, &time);
#endif
return time;
}
};
/**
* Container for wall clock time related functionality not directly provided by C++.
* @tparam T The type of the time-to-struct implementation class.
*/
template <typename T>
struct Time {
/**
* Format the current time with the given strftime format specifiers.
* @param buffer The buffer to write the time string to.
* @param last The last element in the buffer.
* @param format The format according to strftime format specifiers.
* @return The number of characters that were written to the buffer.
*/
static inline size_t Format(char *buffer, const char *last, const char *format) NOACCESS(2) WARN_TIME_FORMAT(3)
{
std::tm time_struct = T::ToTimeStruct(time(nullptr));
#ifndef _MSC_VER
/* GCC bug #39438; unlike for printf where the appropriate attribute prevent the
* "format non literal" warning, that does not happen for strftime. Even though
* format warnings will be created for invalid strftime formats. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif /* _MSC_VER */
return strftime(buffer, last - buffer + 1, format, &time_struct);
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif /* _MSC_VER */
}
};
/** Wall clock time functionality using the local time zone. */
using LocalTime = Time<LocalTimeToStruct>;
/** Wall clock time functionality using the UTC time zone. */
using UTCTime = Time<UTCTimeToStruct>;
#endif