1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 15:02:34 +02:00

Add preliminary NetBSD support

The iconv(3) function on NetBSD has a custom prototype due to old mistake in
the POSIX specification. The issue has been resolved but we keep using original
form with a constified parameter.
This commit is contained in:
Kamil Rytarowski 2016-08-13 21:33:04 +02:00
parent 2f0b24c6ea
commit 0ef224df90
4 changed files with 15 additions and 3 deletions

View File

@ -35,6 +35,8 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_definitions(-DRW_OSX)
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
add_definitions(-DRW_FREEBSD)
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
add_definitions(-DRW_NETBSD)
elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
add_definitions(-DRW_OPENBSD)
set(OPENRW_PLATFORM_LIBS iconv)

View File

@ -539,7 +539,11 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
auto icv = iconv_open("UTF-8", "UTF-16");
char* saveName = (char*)state.basic.saveName;
#if defined(RW_NETBSD)
iconv(icv, (const char**)&saveName, &bytes, &outCur, &outSize);
#else
iconv(icv, &saveName, &bytes, &outCur, &outSize);
#endif
strcpy(state.basic.saveName, outBuff);
BlockDword scriptBlockSize;
@ -1251,7 +1255,11 @@ bool SaveGame::getSaveInfo(const std::string& file, BasicState *basicState)
char* saveName = (char*)basicState->saveName;
// Convert to UTF-8 and copy back to the return struct
#if defined(RW_NETBSD)
iconv(icv, (const char**)&saveName, &bytes, &outCur, &outSize);
#else
iconv(icv, &saveName, &bytes, &outCur, &outSize);
#endif
strcpy(basicState->saveName, outBuff);
return true;
@ -1286,4 +1294,3 @@ std::vector<SaveGameInfo> SaveGame::getAllSaveGameInfo()
return infos;
}

View File

@ -35,7 +35,11 @@ void LoaderGXT::load(GameTexts &texts, FileHandle &file)
char* strbase = tdata+offset;
#if defined(RW_NETBSD)
iconv(icv, (const char**)&strbase, &bytes, &uwot, &outSize);
#else
iconv(icv, &strbase, &bytes, &uwot, &outSize);
#endif
u8buff[len] = '\0';

View File

@ -43,7 +43,7 @@ bool GameConfig::isValid()
std::string GameConfig::getDefaultConfigPath()
{
#if defined(RW_LINUX) || defined(RW_FREEBSD) || defined(RW_OPENBSD)
#if defined(RW_LINUX) || defined(RW_FREEBSD) || defined(RW_NETBSD) || defined(RW_OPENBSD)
char* config_home = getenv("XDG_CONFIG_HOME");
if (config_home != nullptr) {
return std::string(config_home) + "/" + kConfigDirectoryName;
@ -98,4 +98,3 @@ int GameConfig::handler(void* user,
#undef MATCH
}