Unverified Commit 2097b5aa authored by Rafael Kitover's avatar Rafael Kitover
Browse files

wx 2.8 compat fixes, centos support, cmake fixes



Add support for RHEL/centos to installdeps. There is no SFML package.

Add some string compatibility stuff so that everything builds on wx 2.8
unicode builds.

TODO: add travis slaves for 2.8, with and without unicode

Disable the game frame spacer code on 2.8 because it does not work (the
frame does not expand.)

cmake improvements:

- set ENABLE_LTO=OFF for Debug builds by default

- set ENABLE_LINK=OFF if SFML cannot be found and continue

- use better logic for finding wx utilities wx-config and wxrc
Signed-off-by: default avatarRafael Kitover <rkitover@gmail.com>
Closes #395
Closes #297
parent b69fced7
......@@ -116,8 +116,9 @@ option(ENABLE_FFMPEG "Enable ffmpeg A/V recording" ${FFMPEG_DEFAULT})
set(LTO_DEFAULT ON)
if(WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND AMD64)
# lto produces buggy binaries for 64 bit win32
# lto produces buggy binaries for 64 bit win32
# and we generally don't want it when debugging because it makes linking slow
if((WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND AMD64) OR CMAKE_BUILD_TYPE MATCHES Debug)
set(LTO_DEFAULT OFF)
endif()
......@@ -168,7 +169,7 @@ endif()
include_directories(${CMAKE_BINARY_DIR})
configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_BINARY_DIR}/version.h" @ONLY)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG)
else()
add_definitions(-DNDEBUG)
......@@ -196,7 +197,11 @@ endif()
# Look for some dependencies using CMake scripts
find_package(ZLIB REQUIRED)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
find_package(PNG REQUIRED)
if(EXISTS /etc/redhat-release)
......@@ -220,7 +225,13 @@ if(ENABLE_LINK)
if(WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe) AND NOT CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
set(SFML_STATIC_LIBRARIES TRUE)
endif()
find_package(SFML 2 COMPONENTS network system REQUIRED)
find_package(SFML 2 COMPONENTS network system)
if(NOT SFML_FOUND)
message(WARNING "SFML not found, LINK will be disabled")
set(ENABLE_LINK NO)
endif()
endif()
# set the standard libraries all ports use
......@@ -479,7 +490,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra)
else()
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error)
......
......@@ -60,8 +60,8 @@ cmake ..
make -j`nproc`
```
`./installdeps` is supported on MSys2, Linux (Debian/Ubuntu, Fedora, Arch or
Solus) and Mac OS X (homebrew, macports or fink.)
`./installdeps` is supported on MSys2, Linux (Debian/Ubuntu, Fedora, Arch,
Solus and RHEL/CentOS) and Mac OS X (homebrew, macports or fink.)
The Ninja cmake generator is also now supported, including on msys2 and Visual Studio.
......
......@@ -155,6 +155,8 @@ linux_installdeps() {
debian_installdeps
elif [ -f /etc/fedora-release ]; then
fedora_installdeps
elif [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
rhel_installdeps
elif [ -f /etc/arch-release ]; then
archlinux_installdeps
elif [ -f /etc/solus-release ]; then
......@@ -407,7 +409,7 @@ fedora_installdeps() {
fi
# non-multiarch packages first
check sudo dnf -y --nogpgcheck --best --allowerasing install gcc gcc-c++ make cmake ccache git nasm redhat-rpm-config pkgconfig ccache
check sudo dnf -y --nogpgcheck --best --allowerasing install gcc gcc-c++ make cmake ccache git nasm redhat-rpm-config pkgconfig ccache ninja-build
# try to install multiarch libgcc, glibc-devel and pkgconfig if available
if [ -n "$amd64" ]; then
......@@ -427,7 +429,7 @@ fedora_installdeps() {
# this is sometimes necessary for rawhide
set -- --exclude='glibc32*'
fi
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel SFML-devel openal-soft-devel wxGTK3-devel gtk2-devel gtk3-devel; do
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel SFML-devel openal-soft-devel wxGTK3-devel gtk3-devel; do
case $pkg in
*ffmpeg*)
[ -n "$no_ffmpeg" ] && continue
......@@ -535,6 +537,190 @@ fedora_installdeps() {
build_instructions
}
rhel_installdeps() {
rhel=1
ffmpeg=ffmpeg-devel
no_ffmpeg=
rpms_installed=
check_cross
installing
warning=
rhel_release=$(rpm -E %rhel)
tries=3
curdir=$(pwd)
# this source is necessary for mingw packages on rhel, and may be for other things in the future
check sudo yum -y install epel-release
# make sure rpmfusion is installed for ffmpeg
while [ $tries -gt 0 ]; do
mkdir -p "${tmp}/fusion"
cd "${tmp}/fusion"
if ! curl -fLO https://download1.rpmfusion.org/free/el/rpmfusion-free-release-${rhel_release}.noarch.rpm; then
rhel_release=$((rhel_release - 1))
tries=$((tries - 1))
continue
fi
if ! curl -fLO https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-${rhel_release}.noarch.rpm; then
tries=0
break
fi
# check if already installed
if rpm -q rpmfusion-free-release-${rhel_release} >/dev/null 2>&1 && rpm -q rpmfusion-nonfree-release-${rhel_release} >/dev/null 2>&1; then
info_msg 'rpmfusion already installed, good'
break
fi
# otherwise try to install
if ! sudo rpm --nodeps -Uvh ./rpmfusion-*.rpm; then
tries=0
break
fi
break
done
cd "$curdir"
if [ $tries -eq 0 ]; then
warning 'installing rpmfusion repos failed, continuing without ffmpeg'
no_ffmpeg=1
cmake_flags="$cmake_flags -DENABLE_FFMPEG=NO"
fi
# non-multiarch packages first
CMAKE=cmake3
check sudo yum -y install gcc gcc-c++ make cmake3 ccache git nasm redhat-rpm-config pkgconfig ccache ninja-build
# try to install multiarch libgcc, glibc-devel and pkgconfig if available
if [ -n "$amd64" ]; then
for pkg in pkgconfig libgcc glibc-devel; do
if [ "$target" = m32 ]; then
sudo yum -y install "$pkg".i686
else
sudo yum -y install "$pkg".x86_64
fi
done
fi
set --
if [ -z "$target" -o "$target" = m32 ]; then
# try to install both 64 bit and 32 bit versions on 64 bit hosts (see below)
if [ -n "$amd64" ]; then
# this is sometimes necessary for rawhide
set -- --exclude='glibc32*'
fi
warning='RHEL does not currently have SFML packages, LINK support will be disabled'
cmake_flags="$cmake_flags -DENABLE_LINK=NO"
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel openal-soft-devel wxGTK3-devel gtk3-devel wxGTK-devel; do
case $pkg in
*ffmpeg*)
[ -n "$no_ffmpeg" ] && continue
;;
esac
if [ -n "$amd64" ]; then
if [ "$target" = m32 ]; then
set -- "$@" "${pkg}.i686"
else
set -- "$@" "${pkg}.x86_64"
fi
else
set -- "$@" "$pkg"
fi
done
# redhat has a bug where all necessary -devel packages are not pulled in for 32 bit direct -devel deps
# this hack adds them to the list
if [ -n "$amd64" -a "$target" = m32 ]; then
info_msg 'Calculating dependencies, this will take a while..'
curdeps=
newdeps=$@
while [ "$curdeps" != "$newdeps" ]; do
curdeps=$newdeps
set -- $(echo "$@" $(repoquery --deplist "$@" 2>/dev/null | sed -n 's/\.x86_64$/.i686/; s/^ *provider: *\([^ ]*-devel-.*\)$/\1/p' | sort -u) | sed 's/ */\n/g' | sort -u)
newdeps=$@
printf '%s' .
done
echo
info_msg 'Done'
## install the RPMs with rpm --force get around file conflicts
host_rpms=$(echo "$@" | sed 's/\.i686//g')
# first update the host arch versions to reduce chances of conflicts
check sudo yum -y install $host_rpms
oldcwd=$PWD
mkdir "$tmp/rpms"
cd "$tmp/rpms"
check sudo yum -y download "$@"
# first try installing with yum to pull in deps
check sudo yum -y --skip-broken install *.rpm
# follow up with rpm --force to ignore conflicts
check sudo rpm -Uvh --force *.rpm
rm -f *.rpm
# reinstall the host rpms to make sure any overwritten files are the host version
check sudo yum -y download $host_rpms
check sudo yum -y --skip-broken install *.rpm
check sudo rpm -Uvh --force *.rpm
cd "$oldcwd"
rm -rf "$tmp/rpms"
ffmpeg=ffmpeg-devel.i686
rpms_installed=1
fi
else # mingw build
set -- "$@" pkgconfig
case "$target" in
mingw-w64-i686)
target=mingw32
cmake_flags="$cmake_flags -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-MinGW-w64-i686.cmake -DENABLE_LINK=NO"
;;
mingw-w64-x86_64)
target=mingw64
cmake_flags="$cmake_flags -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-MinGW-w64-x86_64.cmake -DENABLE_LINK=NO"
;;
*)
error 'unknown cross target (this should not happen)'
;;
esac
# install static deps
for pkg in zlib gettext libpng SDL2 wxWidgets; do
set -- "$@" "${target}-${pkg}-static"
done
# install deps that are not available as static
for pkg in openal-soft; do
set -- "$@" "${target}-${pkg}"
done
warning='SFML is required for LINK support, RHEL/EPEL does not currently have a MinGW SFML package, if you want LINK support you will need to install it manually'
fi
[ -z "$rpms_installed" ] && check sudo yum -y install "$@"
if ! rpm -q $ffmpeg >/dev/null 2>&1; then
warning 'ffmpeg failed to install (probably due to conflicts)'
cmake_flags="$cmake_flags -DENABLE_FFMPEG=NO"
fi
[ -n "$warning" ] && warning "$warning"
build_instructions
}
suse_installdeps() {
suse=1
check_cross
......
......@@ -68,7 +68,7 @@ endif()
if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
# set up wxwidgets stuff
add_definitions(-D_UNICODE -DUNICODE -DWXUSINGDLL -DwxUSE_GUI=1 -D__WXMSW__)
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-D_DEBUG)
include_directories(${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/debug/lib/mswud)
include_directories(${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/include)
......@@ -117,7 +117,7 @@ if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
file(COPY ${_VCPKG_ROOT_DIR}/installed/${WINARCH}-windows/bin/SDL2.dll DESTINATION ${CMAKE_BINARY_DIR})
endif()
else()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm
endif()
......@@ -156,12 +156,42 @@ else()
set(wxWidgets_USE_UNICODE ON)
function(find_wx_util var util)
foreach(conf_suffix gtk4 gtk3 "")
foreach(major_version 4 3 2 "")
foreach(minor_version RANGE 0 101)
unset(suffix)
if(conf_suffix)
set(suffix "-${conf_suffix}")
endif()
if(major_version)
set(suffix "${suffix}-${major_version}")
endif()
if(NOT minor_version EQUAL 101)
set(suffix "${suffix}.${minor_version}")
endif()
find_program(${var} NAMES "${util}${suffix}")
if(${${var}})
return()
endif()
endforeach()
endforeach()
endforeach()
endfunction()
# Check for gtk4 then gtk3 packages first, some dists like arch rename the
# wx-config utility for these packages to e.g. wx-config-gtk3
#
# Do not do the check if the WX_CONFIG env var is set.
if(NOT WIN32 AND NOT APPLE AND "$ENV{WX_CONFIG}" STREQUAL "")
find_program(wxWidgets_CONFIG_EXECUTABLE NAMES wx-config-gtk4 wx-config-gtk3 wx-config)
# Do not do the check if the WX_CONFIG env var is set or the cmake variable
# is set
if(NOT wxWidgets_CONFIG_EXECUTABLE)
if(DEFINED ENV{WX_CONFIG})
separate_arguments(wxWidgets_CONFIG_EXECUTABLE UNIX_COMMAND $ENV{WX_CONFIG})
else()
find_wx_util(wxWidgets_CONFIG_EXECUTABLE wx-config)
endif()
endif()
# adv is for wxAboutBox
......@@ -180,7 +210,7 @@ else()
include_directories(${wxWidgets_INCLUDE_DIRS})
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_BUILD_TYPE MATCHES Debug)
# tell wx to enable debug mode if possible, if the cmake module did not do it for us
execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE} --debug=yes" RESULT_VARIABLE WX_CONFIG_DEBUG OUTPUT_QUIET ERROR_QUIET)
......@@ -257,13 +287,19 @@ int WINAPI DetourMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uT
class MyApp : public wxAppConsole {
public:
virtual bool OnInit();
// this is necessary for 2.8 to make the class non-abstract
virtual int OnRun() { return 0; }
};
bool MyApp::OnInit() {
exit(0);
}
#if wxCHECK_VERSION(2, 9, 0)
wxIMPLEMENT_APP_NO_MAIN(MyApp);
#else
IMPLEMENT_APP_NO_MAIN(MyApp);
#endif
int main(int argc, char** argv)
{
......@@ -518,8 +554,27 @@ include(HostCompile)
host_compile(${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c ${BIN2C})
if(WXRC)
separate_arguments(WXRC UNIX_COMMAND "${WXRC}")
else()
separate_arguments(WXRC UNIX_COMMAND ${WXRC})
elseif(DEFINED ENV{WXRC})
separate_arguments(WXRC UNIX_COMMAND $ENV{WXRC})
elseif(wxWidgets_CONFIG_EXECUTABLE)
execute_process(
COMMAND ${wxWidgets_CONFIG_EXECUTABLE} --utility=wxrc
OUTPUT_VARIABLE WXRC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# check if the path from wx-config is good
if(NOT EXISTS ${WXRC})
unset(WXRC)
endif()
endif()
if(NOT WXRC)
find_wx_util(WXRC wxrc)
endif()
if(NOT WXRC)
message(WARNING "could not find your wxrc executable")
set(WXRC wxrc)
endif()
......@@ -723,7 +778,7 @@ endif()
if(CMAKE_COMPILER_IS_GNUCXX)
if(WIN32)
# Build a console app in debug mode on Windows
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,console")
else()
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,windows")
......@@ -767,7 +822,7 @@ if(APPLE)
# bundle dylibs and relink them for releasing .app
# also install translations into the .app
# but only in Release mode
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
add_custom_command(
TARGET visualboyadvance-m POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/tools/osx/third_party_libs_tool ./visualboyadvance-m.app
......
......@@ -527,7 +527,7 @@ EVT_HANDLER_MASK(RomInformation, "ROM information...", CMDEN_GB | CMDEN_GBA)
} while (0)
#define setblabs(id, b, ts) \
do { \
s.Printf(wxT("%02x (%s)"), (unsigned int)b, ts); \
s.Printf(wxT("%02x (%s)"), (unsigned int)b, ts.c_str()); \
setlab(id); \
} while (0)
#define setlabs(id, ts, l) \
......@@ -865,9 +865,9 @@ EVT_HANDLER_MASK(ImportBatteryFile, "Import battery file...", CMDEN_GB | CMDEN_G
wxString msg;
if (panel->emusys->emuReadBattery(fn.mb_fn_str()))
msg.Printf(_("Loaded battery %s"), fn.mb_str());
msg.Printf(_("Loaded battery %s"), fn.c_str());
else
msg.Printf(_("Error loading battery %s"), fn.mb_str());
msg.Printf(_("Error loading battery %s"), fn.c_str());
systemScreenMessage(msg);
}
......@@ -903,7 +903,7 @@ EVT_HANDLER_MASK(ImportGamesharkCodeFile, "Import GameShark code file...", CMDEN
wxFFile f(fn, wxT("rb"));
if (!f.IsOpened()) {
wxLogError(_("Cannot open file %s"), fn.mb_str());
wxLogError(_("Cannot open file %s"), fn.c_str());
return;
}
......@@ -913,7 +913,7 @@ EVT_HANDLER_MASK(ImportGamesharkCodeFile, "Import GameShark code file...", CMDEN
char buf[14];
if (f.Read(&len, sizeof(len)) != sizeof(len) || wxUINT32_SWAP_ON_BE(len) != 14 || f.Read(buf, 14) != 14 || memcmp(buf, "SharkPortCODES", 14)) {
wxLogError(_("Unsupported code file %s"), fn.mb_str());
wxLogError(_("Unsupported code file %s"), fn.c_str());
return;
}
......@@ -983,9 +983,9 @@ EVT_HANDLER_MASK(ImportGamesharkCodeFile, "Import GameShark code file...", CMDEN
}
if (res)
msg.Printf(_("Loaded code file %s"), fn.mb_str());
msg.Printf(_("Loaded code file %s"), fn.c_str());
else
msg.Printf(_("Error loading code file %s"), fn.mb_str());
msg.Printf(_("Error loading code file %s"), fn.c_str());
systemScreenMessage(msg);
}
......@@ -1031,9 +1031,9 @@ EVT_HANDLER_MASK(ImportGamesharkActionReplaySnapshot,
}
if (res)
msg.Printf(_("Loaded snapshot file %s"), fn.mb_str());
msg.Printf(_("Loaded snapshot file %s"), fn.c_str());
else
msg.Printf(_("Error loading snapshot file %s"), fn.mb_str());
msg.Printf(_("Error loading snapshot file %s"), fn.c_str());
systemScreenMessage(msg);
}
......@@ -1056,9 +1056,9 @@ EVT_HANDLER_MASK(ExportBatteryFile, "Export battery file...", CMDEN_GB | CMDEN_G
wxString msg;
if (panel->emusys->emuWriteBattery(fn.mb_fn_str()))
msg.Printf(_("Wrote battery %s"), fn.mb_str());
msg.Printf(_("Wrote battery %s"), fn.c_str());
else
msg.Printf(_("Error writing battery %s"), fn.mb_str());
msg.Printf(_("Error writing battery %s"), fn.c_str());
systemScreenMessage(msg);
}
......@@ -1097,11 +1097,11 @@ EVT_HANDLER_MASK(ExportGamesharkSnapshot, "Export GameShark snapshot...", CMDEN_
// FIXME: this will fail on big-endian machines if file format is
// little-endian
// fix in GBA.cpp
if (CPUWriteGSASnapshot(fn.mb_str(), tit->GetValue().mb_str(),
dsc->GetValue().mb_str(), n->GetValue().mb_str()))
msg.Printf(_("Saved snapshot file %s"), fn.mb_str());
if (CPUWriteGSASnapshot(fn.utf8_str(), tit->GetValue().utf8_str(),
dsc->GetValue().utf8_str(), n->GetValue().utf8_str()))
msg.Printf(_("Saved snapshot file %s"), fn.c_str());
else
msg.Printf(_("Error saving snapshot file %s"), fn.mb_str());
msg.Printf(_("Error saving snapshot file %s"), fn.c_str());
systemScreenMessage(msg);
}
......@@ -1141,7 +1141,7 @@ EVT_HANDLER_MASK(ScreenCapture, "Screen capture...", CMDEN_GB | CMDEN_GBA)
panel->emusys->emuWriteBMP(fn.mb_fn_str());
wxString msg;
msg.Printf(_("Wrote snapshot %s"), fn.mb_str());
msg.Printf(_("Wrote snapshot %s"), fn.c_str());
systemScreenMessage(msg);
}
......@@ -1937,7 +1937,7 @@ void MainFrame::GDBBreak()
if (!debugOpenPty())
return;
msg.Printf(_("Waiting for connection at %s"), debugGetSlavePty().mb_str());
msg.Printf(_("Waiting for connection at %s"), debugGetSlavePty().c_str());
} else
#endif
{
......@@ -2242,7 +2242,7 @@ EVT_HANDLER(GameBoyAdvanceConfigure, "Game Boy Advance options...")
vba_over.append(wxTextFile::GetEOL());
fn.Mkdir(0777, wxPATH_MKDIR_FULL);
wxTempFileOutputStream fos(fn.GetFullPath());
fos.Write(vba_over.mb_str(), vba_over.size());
fos.Write(vba_over.c_str(), vba_over.size());
fos.Commit();
}
}
......
......@@ -17,7 +17,6 @@
#include <wx/filepicker.h>
#include <wx/progdlg.h>
#include <wx/spinctrl.h>
#include <wx/valnum.h>
#include <wx/stockitem.h>
#include <wx/tokenzr.h>
#include <wx/txtstrm.h>
......@@ -88,7 +87,7 @@ public:
return;
if (!server) {
bool valid = SetLinkServerHost(gopts.link_host.mb_str());
bool valid = SetLinkServerHost(gopts.link_host.c_str());
if (!valid) {
wxMessageBox(_("You must enter a valid host name"),
......@@ -111,10 +110,10 @@ public:
char host[length];
GetLinkServerHost(host, length);
title.Printf(_("Waiting for clients..."));
connmsg.Printf(_("Server IP address is: %s\n"), wxString(host, wxConvLibc).mb_str());
connmsg.Printf(_("Server IP address is: %s\n"), wxString(host, wxConvLibc).c_str());
} else {
title.Printf(_("Waiting for connection..."));
connmsg.Printf(_("Connecting to %s\n"), gopts.link_host.mb_str());
connmsg.Printf(_("Connecting to %s\n"), gopts.link_host.c_str());
}
// Init link
......@@ -436,9 +435,9 @@ public:
if (isgb) {
if (!ce_type)
gbAddGsCheat(tok.mb_str(), ce_desc.mb_str());
gbAddGsCheat(tok.utf8_str(), ce_desc.utf8_str());
else
gbAddGgCheat(tok.mb_str(), ce_desc.mb_str());
gbAddGgCheat(tok.utf8_str(), ce_desc.utf8_str());
} else {
// Flashcart CHT format
if (tok.Contains(wxT("="))) {
......@@ -446,16 +445,16 @@ public:
}
// Generic Code
else if (tok.Contains(wxT(":")))
cheatsAddCheatCode(tok.mb_str(), ce_desc.mb_str());
cheatsAddCheatCode(tok.utf8_str(), ce_desc.utf8_str());
// following determination of type by lengths is
// same used by win32 and gtk code
// and like win32/gtk code, user-chosen fmt is ignored
else if (tok.size() == 12) {
tok = tok.substr(0, 8) + wxT(' ') + tok.substr(8);
cheatsAddCBACode(tok.mb_str(), ce_desc.mb_str());
cheatsAddCBACode(tok.utf8_str(), ce_desc.utf8_str());
} else if (tok.size() == 16)
// not sure why 1-tok is !v3 and 2-tok is v3..
cheatsAddGSACode(tok.mb_str(), ce_desc.mb_str(), false);
cheatsAddGSACode(tok.utf8_str(), ce_desc.utf8_str(), false);
// CBA codes are assumed to be N+4, and anything else
// is assumed to be GSA v3 (although I assume the
// actual formats should be 8+4 and 8+8)
......@@ -463,18 +462,18 @@ public:
if (!tk.HasMoreTokens()) {
// throw an error appropriate to chosen type
if (ce_type == 1) // GSA
cheatsAddGSACode(tok.mb_str(), ce_desc.mb_str(), false);
cheatsAddGSACode(tok.utf8_str(), ce_desc.utf8_str(), false);
else
cheatsAddCBACode(tok.mb_str(), ce_desc.mb_str());
cheatsAddCBACode(tok.utf8_str(), ce_desc.utf8_str());
} else {
wxString tok2 = tk.GetNextToken();
if (tok2.size() == 4) {
tok += wxT(' ') + tok2;
cheatsAddCBACode(tok.mb_str(), ce_desc.mb_str());
cheatsAddCBACode(tok.utf8_str(), ce_desc.utf8_str());
} else {
tok += tok2;
cheatsAddGSACode(tok.mb_str(), ce_desc.mb_str(), true);
cheatsAddGSACode(tok.utf8_str(), ce_desc.utf8_str(), true);
}
}
}
......@@ -624,7 +623,7 @@ public:
} else if (ce_desc != odesc) {
*dirty = true;
char* p = isgb ? gbCheatList[id].cheatDesc : cheatsList[id].desc;
strncpy(p, ce_desc.mb_str(), sizeof(cheatsList[0].desc));
strncpy(p, ce_desc.utf8_str(), sizeof(cheatsList[0].desc));
p[sizeof(cheatsList[0].desc) - 1] = 0;
item1.SetId(id);
item1.SetText(wxString(p, wxConvUTF8));
......@@ -674,7 +673,7 @@ void CheatList_t::ParseChtLine(wxString desc, wxString tok)
wxString cheat_value;