This commit is contained in:
DepressedTWM 2026-08-01 00:10:23 +04:00
parent 4c430bcebc
commit 885b56b3dc
85 changed files with 179 additions and 202 deletions

View file

@ -8,7 +8,7 @@ option(DEBUG "Debug mode" OFF)
option(SANITIZERS "Enable sanitizers" OFF)
option(NATIVE "Use native instructions(for local use only)" OFF)
#x86, arm64, ia-64
option(CPU_ARCH "Enter here your target arch" "x86")
option(CPU_ARCH "CPU arch" "x86")
#Configuration
set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE)
@ -245,11 +245,6 @@ macro(ProcessWithXXD outvar inputfile outdir)
)
endmacro()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/xxdhack)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/xxdhack
)
foreach(item ${EMBEDDED_INPUT})
ProcessWithXXD(EMBEDDED_SOURCE ${item} ${CMAKE_CURRENT_BINARY_DIR})
endforeach()
@ -305,7 +300,6 @@ set(BINDING_SOURCE
source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS})
################
# Настройки зависимые от компилятора
if (MSVC)
@ -321,9 +315,10 @@ if (MSVC)
endif()
else()
if(NATIVE)
add_compile_options("-march=native -mtune=native")
endif()
if(SANITIZERS)
# ASan + Ruby = shit :<
set(SANITIZERS "undefined,leak,shift,shift-base,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin,pointer-subtract,pointer-compare")
add_compile_options(-fsanitize=${SANITIZERS})
add_link_options(-fsanitize=${SANITIZERS})
@ -368,12 +363,14 @@ else()
-mnoreturn-no-callee-saved-registers
-mrelax-cmpxchg-loop)
elseif(CPU_ARCH MATCHES "arm64")
# TODO: check is it really usefull:3
add_compile_options(
-mlow-precision-recip-sqrt
-mlow-precision-sqrt
-mlow-precision-div
)
elseif(CPU_ARCH MATCHES "ia-64")
# In theory it must make game work better on IA-64?
add_compile_options(
-minline-float-divide-min-latency
-minline-float-divide-max-throughput
@ -383,7 +380,6 @@ else()
-minline-sqrt-max-throughput
)
endif()
endif()
endif()
@ -426,7 +422,6 @@ find_package_handle_standard_args(pixman-1 DEFAULT_MSG PIXMAN_LIBRARY PIXMAN_INC
mark_as_advanced(PIXMAN_INCLUDE_DIR PIXMAN_LIBRARY)
find_package(OpenSSL CONFIG REQUIRED COMPONENTS Crypto)
pkg_check_modules(SIGC2 REQUIRED sigc++-2.0)
pkg_check_modules(LIBZIP REQUIRED libzip)
target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFINES})
target_include_directories(${PROJECT_NAME} PRIVATE src include ${PIXMAN_INCLUDE_DIR} ${SIGC2_INCLUDE_DIRS}
@ -439,12 +434,11 @@ physfs ${PIXMAN_LIBRARY} ${SIGC2_LIBRARIES} ${PLATFORM_LIBRARIES}
${Ruby_LIBRARIES} Boost::boost Boost::chrono ${Boost_LIBRARIES}
${VORBISFILE_LIBRARIES} ZLIB::ZLIB ${PLATFORM_LIBS})
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBZIP_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBZIP_LIBRARIES} OpenSSL::Crypto)
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::Crypto)
if(STEAM)
add_subdirectory(steamshim_parent)
# steam_appid.txt
configure_file(
"${CMAKE_SOURCE_DIR}/steam_appid.txt"

View file

@ -1 +1,2 @@
# How Sunshine ModLoader work
todo lol

View file

@ -24,4 +24,3 @@ added icons and way to disable options in settings
fixed segfault while to fast window size changing
updated cg_blue picture
Deleted useless hooks

View file

@ -1,7 +1,7 @@
#!/bin/bash
set -euo pipefail
# User-configurable variables.
oneshot_id=420530
oneshot_id="$(cat steam_appid.txt)"
STEAMWORKS_PATH=$(realpath ..)/steamworks
cmake . -B build/

View file

@ -1,44 +1,34 @@
#!/bin/sh
set -e
set -ueo pipefail
cd `dirname $0`
# User-configurable variables
mac_version="1.1.1"
make_threads=8
ONESHOT_PATH=$HOME/Library/Application\ Support/Steam/steamapps/common/OneShot
# Colors
white="\033[0;37m" # White - Regular
bold="\033[1;37m" # White - Bold
cyan="\033[1;36m" # Cyan - Bold
green="\033[1;32m" # Green - Bold
color_reset="\033[0m" # Reset Colors
use_qmake=True
echo "${white}Compiling ${bold}Sunshine ${white}engine for macOS...${color_reset}\n"
echo "Compiling Sunshine engine for macOS...\n"
# Generate makefile and build main + journal
if [[ $use_qmake == True ]]
then
echo "-> ${cyan}Generate makefile...${color_reset}"
echo "-> Generate makefile..."
qmake MRIVERSION=3.3
echo "-> ${cyan}Compile engine...${color_reset}"
make -j${make_threads}
echo "-> ${cyan}Compile steamshim...${color_reset}"
echo "-> Compile engine..."
make -j"${nproc}"
echo "-> Compile steamshim..."
# cd steamshim_parent
# mkdir build && cd build
# cmake ..
# STEAMWORKS=./steamworks make -j${make_threads}
# cd ../..
else
echo "${bold}WARNING: Conan/CMake method not ready yet.${color_reset}"
echo "WARNING: Conan/CMake method not ready yet."
fi
echo "-> ${cyan}Compile journal...${color_reset}"
echo "-> Compile journal..."
pyinstaller journal/unix/journal.spec --onefile --windowed
# Create app bundles
echo "-> ${cyan}Create app bundles...${color_reset}"
echo "-> Create app bundles..."
OSX_App="OneShot.app"
ContentsDir="$OSX_App/Contents"
LibrariesDir="$OSX_App/Contents/Libraries"
@ -67,26 +57,24 @@ mv OneShot.app/Contents/MacOS/OneShot OneShot.app/Contents/Resources/OneShot
cp -r dist/_______.app _______.app
# Set version number
echo "-> ${cyan}Set version number...${color_reset}"
echo "-> Set version number..."
rm -f OneShot.app/Contents/Info.plist
rm -f _______.app/Contents/Info.plist
m4 patches/mac/Info.plist.in -DONESHOTMACVERSION=$mac_version > OneShot.app/Contents/Info.plist
m4 patches/mac/JournalInfo.plist.in -DONESHOTMACVERSION=$mac_version > _______.app/Contents/Info.plist
# Compile scripts
echo "-> ${cyan}Compile xScripts.rxdata...${color_reset}"
echo "-> Compile xScripts.rxdata..."
ruby rpgscript.rb ./scripts "$ONESHOT_PATH"
cp "$ONESHOT_PATH/Data/xScripts.rxdata" .
echo "-> ${cyan}Install OneShot apps to Steam directory...${color_reset}"
echo "-> Install OneShot apps to Steam directory..."
cp -rf "./OneShot.app" "$ONESHOT_PATH"
cp -rf "./_______.app" "$ONESHOT_PATH"
# Cleanup
echo "-> ${cyan}Cleanup files...${color_reset}"
echo "-> Cleanup files..."
# make clean
rm -rf journal/unix/__pycache__
rm -rf build
rm -rf dist
echo "\n${green}Complete!"

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -1,5 +1,4 @@
#pragma once
#include <sigc++/connection.h>
#include "debugwriter.h"

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -5,7 +5,7 @@
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is SDL_free software: you can redistribute it and/or modify
** mkxp 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, either version 2 of the License, or
** (at your option) any later version.

View file

@ -4,7 +4,7 @@
Copyright (c) 2007 Red Hat, Inc.
Permission is hereby granted, SDL_free of charge, to any person
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
@ -28,8 +28,6 @@
#include "xdg-user-dir-lookup.h"
#include <SDL3/SDL_stdinc.h>
#include <stdio.h>
#include <stdlib.h>
/**
* xdg_user_dir_lookup_with_fallback:
* @type: a string specifying the type of directory
@ -62,7 +60,6 @@ char * xdg_user_dir_lookup_with_fallback (const char *type, const char *fallback
config_home = SDL_getenv("XDG_CONFIG_HOME");
if (config_home == NULL || config_home[0] == 0){
//SDL_strlen("/.config/user-dirs.dirs") + 1
config_file = (char*)SDL_malloc(SDL_strlen(home_dir) + 23);
if (config_file == NULL)
goto error;

View file

@ -1,18 +1,36 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.28.3)
set(STEAMWORKS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../steamworks" CACHE PATH "Path to Steamworks folder")
set(GAME_LAUNCH_NAME "oneshot" CACHE STRING "Game launch name")
option(DEBUG "Debug" OFF)
option(NATIVE "Use native instructions(for local use only)" OFF)
set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE)
set(SANITIZERS "address,undefined,leak,shift,shift-base,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin,pointer-subtract,pointer-compare")
if(DEBUG)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
add_definitions(-DSTEAMSHIM_DEBUG)
add_compile_options(-fsanitize=${SANITIZERS} -g)
add_link_options(-fsanitize=${SANITIZERS})
else()
add_compile_options(-O2 -ffast-math -fipa-pta -ftree-vectorize -fstdarg-opt -fomit-frame-pointer -frename-registers -ffunction-sections -fdata-sections -fvisibility=hidden)
add_link_options(-Wl,-O2 -Wl,--gc-sections -Wl,--as-needed -Wl,--strip-debug -Wl,--no-undefined)
if(!WIN32)
add_compile_options(-flto)
endif()
add_compile_options(
-O2
-ffast-math
-fipa-pta
-ftree-vectorize
-fstdarg-opt
-fomit-frame-pointer
-frename-registers
-ffunction-sections
-fdata-sections
-fvisibility=hidden
-flto)
add_link_options(
-Wl,-O2
-Wl,--gc-sections
-Wl,--as-needed
-Wl,--strip-debug
-Wl,--no-undefined)
endif()
if(NATIVE)
add_compile_options("-march=native -mtune=native")
endif()
set(SOURCES
@ -20,15 +38,9 @@ set(SOURCES
)
include_directories(${STEAMWORKS_PATH}/public)
add_definitions(-DGAME_LAUNCH_NAME="${GAME_LAUNCH_NAME}")
find_package(SDL3 CONFIG)
IF(DEBUG)
add_definitions(-DSTEAMSHIM_DEBUG)
ENDIF()
IF(APPLE)
find_library(steamworks NAMES steam_api steam_api64 PATHS ${STEAMWORKS_PATH}/redistributable_bin/osx32)
ELSEIF(WIN32)

View file

@ -1,41 +1,33 @@
#ifndef GAME_LAUNCH_NAME
#define GAME_LAUNCH_NAME "oneshot"
#define GAME_LAUNCH_NAME "oneshot"
#endif
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN 1
#define UNICODE
#include <windows.h>
typedef PROCESS_INFORMATION ProcessType;
typedef HANDLE PipeType;
#define NULLPIPE NULL
#define LLUFMT "%I64u"
#define WIN32_LEAN_AND_MEAN 1
#define UNICODE
#include <windows.h>
typedef PROCESS_INFORMATION ProcessType;
typedef HANDLE PipeType;
#define NULLPIPE NULL
#define LLUFMT "%I64u"
#else
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <signal.h>
#include <fcntl.h>
typedef pid_t ProcessType;
typedef int PipeType;
#define NULLPIPE -1
#define LLUFMT "%llu"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <signal.h>
#include <fcntl.h>
typedef pid_t ProcessType;
typedef int PipeType;
#define NULLPIPE -1
#define LLUFMT "%llu"
#endif
#include <stdlib.h>
#include "steam/steam_api.h"
#ifdef STEAMSHIM_DEBUG
#define dbgpipe printf
#else
static inline void dbgpipe(const char *fmt, ...) {
(void)fmt;
}
#endif
#include <SDL3/SDL_messagebox.h>
#include <SDL3/SDL_log.h>
#include <SDL3/SDL_stdinc.h>
/* platform-specific mainline calls this. */
static int mainline(void);
@ -44,19 +36,22 @@ static int mainline(void);
static void fail(const char *err);
static bool writePipe(PipeType fd, const void *buf, const unsigned int _len);
static int readPipe(PipeType fd, void *buf, const unsigned int _len);
static bool createPipes(PipeType *pPipeParentRead, PipeType *pPipeParentWrite,
PipeType *pPipeChildRead, PipeType *pPipeChildWrite);
static bool createPipes(PipeType *pPipeParentRead, PipeType *pPipeParentWrite, PipeType *pPipeChildRead, PipeType *pPipeChildWrite);
static void closePipe(PipeType fd);
static bool setEnvVar(const char *key, const char *val);
static bool launchChild(ProcessType *pid);
static int closeProcess(ProcessType *pid);
#ifdef _WIN32
static void fail(const char *err){
MessageBoxA(NULL, err, "ERROR", MB_ICONERROR | MB_OK);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Steamshim Error", err, NULL);
#ifdef _WIN32
ExitProcess(1);
#else
_exit(1);
#endif
} // fail
#ifdef _WIN32
static bool writePipe(PipeType fd, const void *buf, const unsigned int _len){
const DWORD len = (DWORD) _len;
DWORD bw = 0;
@ -158,13 +153,6 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
#else // everyone else that isn't Windows.
static void fail(const char *err){
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Steamshim parent error", err, NULL);
fprintf(stderr, "%s\n", err);
_exit(1);
} // fail
static bool writePipe(PipeType fd, const void *buf, const unsigned int _len){
const ssize_t len = (ssize_t) _len;
ssize_t bw;
@ -222,7 +210,7 @@ static bool launchChild(ProcessType *pid){
// we're the child.
GArgv[0] = SDL_strdup("./" GAME_LAUNCH_NAME);
dbgpipe("Starting %s\n", GArgv[0]);
SDL_log("Starting %s\n", GArgv[0]);
execvp(GArgv[0], GArgv);
// still here? It failed! Terminate, closing child's ends of the pipes.
_exit(1);
@ -249,7 +237,6 @@ int main(int argc, char **argv){
// THE ACTUAL PROGRAM.
class SteamBridge;
static ISteamUserStats *GSteamStats = NULL;
static ISteamUtils *GSteamUtils = NULL;
static ISteamUser *GSteamUser = NULL;
@ -319,33 +306,33 @@ static bool writeString(PipeType fd, ShimEvent event, const char *str){
uint8 buf[256];
buf[0] = SDL_strlen(str) + 2;
buf[1] = (uint8) event;
strcpy((char *) buf + 2, str);
SDL_strlcpy((char *) buf + 2, str, sizeof(buf + 2));
return writePipe(fd, buf, buf[0] + 1);
} // writeString
static inline bool writeBye(PipeType fd){
dbgpipe("Parent sending SHIMEVENT_BYE().\n");
SDL_log("Parent sending SHIMEVENT_BYE().\n");
return write1ByteCmd(fd, SHIMEVENT_BYE);
} // writeBye
static inline bool writeStatsReceived(PipeType fd, const bool okay){
dbgpipe("Parent sending SHIMEVENT_STATSRECEIVED(%sokay).\n", okay ? "" : "!");
SDL_log("Parent sending SHIMEVENT_STATSRECEIVED(%sokay).\n", okay ? "" : "!");
return write2ByteCmd(fd, SHIMEVENT_STATSRECEIVED, okay ? 1 : 0);
} // writeStatsReceived
static inline bool writeStatsStored(PipeType fd, const bool okay){
dbgpipe("Parent sending SHIMEVENT_STATSSTORED(%sokay).\n", okay ? "" : "!");
SDL_log("Parent sending SHIMEVENT_STATSSTORED(%sokay).\n", okay ? "" : "!");
return write2ByteCmd(fd, SHIMEVENT_STATSSTORED, okay ? 1 : 0);
} // writeStatsStored
static bool writeAchievementSet(PipeType fd, const char *name, const bool enable, const bool okay){
uint8 buf[256];
uint8 *ptr = buf+1;
dbgpipe("Parent sending SHIMEVENT_SETACHIEVEMENT('%s', %senable, %sokay).\n", name, enable ? "" : "!", okay ? "" : "!");
SDL_log("Parent sending SHIMEVENT_SETACHIEVEMENT('%s', %senable, %sokay).\n", name, enable ? "" : "!", okay ? "" : "!");
*(ptr++) = (uint8) SHIMEVENT_SETACHIEVEMENT;
*(ptr++) = enable ? 1 : 0;
*(ptr++) = okay ? 1 : 0;
strcpy((char *) ptr, name);
SDL_strlcpy((char *) ptr, name, buf);
ptr += SDL_strlen(name) + 1;
buf[0] = (uint8) ((ptr-1) - buf);
return writePipe(fd, buf, buf[0] + 1);
@ -354,19 +341,19 @@ static bool writeAchievementSet(PipeType fd, const char *name, const bool enable
static bool writeAchievementGet(PipeType fd, const char *name, const int status, const uint64 time){
uint8 buf[256];
uint8 *ptr = buf+1;
dbgpipe("Parent sending SHIMEVENT_GETACHIEVEMENT('%s', status %d, time " LLUFMT ").\n", name, status, (unsigned long long) time);
SDL_log("Parent sending SHIMEVENT_GETACHIEVEMENT('%s', status %d, time " LLUFMT ").\n", name, status, (unsigned long long) time);
*(ptr++) = (uint8) SHIMEVENT_GETACHIEVEMENT;
*(ptr++) = (uint8) status;
SDL_memcpy(ptr, &time, sizeof (time));
ptr += sizeof (time);
strcpy((char *) ptr, name);
SDL_strlcpy((char *) ptr, name, buf);
ptr += SDL_strlen(name) + 1;
buf[0] = (uint8) ((ptr-1) - buf);
return writePipe(fd, buf, buf[0] + 1);
} // writeAchievementGet
static inline bool writeResetStats(PipeType fd, const bool alsoAch, const bool okay){
dbgpipe("Parent sending SHIMEVENT_RESETSTATS(%salsoAchievements, %sokay).\n", alsoAch ? "" : "!", okay ? "" : "!");
SDL_log("Parent sending SHIMEVENT_RESETSTATS(%salsoAchievements, %sokay).\n", alsoAch ? "" : "!", okay ? "" : "!");
return write3ByteCmd(fd, SHIMEVENT_RESETSTATS, alsoAch ? 1 : 0, okay ? 1 : 0);
} // writeResetStats
@ -377,29 +364,29 @@ static bool writeStatThing(PipeType fd, const ShimEvent ev, const char *name, co
*(ptr++) = okay ? 1 : 0;
SDL_memcpy(ptr, val, vallen);
ptr += vallen;
strcpy((char *) ptr, name);
SDL_memcpy((char *) ptr, name, buf);
ptr += SDL_strlen(name) + 1;
buf[0] = (uint8) ((ptr-1) - buf);
return writePipe(fd, buf, buf[0] + 1);
} // writeStatThing
static inline bool writeSetStatI(PipeType fd, const char *name, const int32 val, const bool okay){
dbgpipe("Parent sending SHIMEVENT_SETSTATI('%s', val %d, %sokay).\n", name, (int) val, okay ? "" : "!");
SDL_log("Parent sending SHIMEVENT_SETSTATI('%s', val %d, %sokay).\n", name, (int) val, okay ? "" : "!");
return writeStatThing(fd, SHIMEVENT_SETSTATI, name, &val, sizeof (val), okay);
} // writeSetStatI
static inline bool writeSetStatF(PipeType fd, const char *name, const float val, const bool okay){
dbgpipe("Parent sending SHIMEVENT_SETSTATF('%s', val %f, %sokay).\n", name, val, okay ? "" : "!");
SDL_log("Parent sending SHIMEVENT_SETSTATF('%s', val %f, %sokay).\n", name, val, okay ? "" : "!");
return writeStatThing(fd, SHIMEVENT_SETSTATF, name, &val, sizeof (val), okay);
} // writeSetStatF
static inline bool writeGetStatI(PipeType fd, const char *name, const int32 val, const bool okay){
dbgpipe("Parent sending SHIMEVENT_GETSTATI('%s', val %d, %sokay).\n", name, (int) val, okay ? "" : "!");
SDL_log("Parent sending SHIMEVENT_GETSTATI('%s', val %d, %sokay).\n", name, (int) val, okay ? "" : "!");
return writeStatThing(fd, SHIMEVENT_GETSTATI, name, &val, sizeof (val), okay);
} // writeGetStatI
static inline bool writeGetStatF(PipeType fd, const char *name, const float val, const bool okay){
dbgpipe("Parent sending SHIMEVENT_GETSTATF('%s', val %f, %sokay).\n", name, val, okay ? "" : "!");
SDL_log("Parent sending SHIMEVENT_GETSTATF('%s', val %f, %sokay).\n", name, val, okay ? "" : "!");
return writeStatThing(fd, SHIMEVENT_GETSTATF, name, &val, sizeof (val), okay);
} // writeGetStatF
@ -547,12 +534,12 @@ static bool processCommand(const uint8 *buf, unsigned int buflen, PipeType fd){
break;
case SHIMCMD_GETPERSONANAME:
dbgpipe("Parent sending SHIMEVENT_GETPERSONANAME.\n");
SDL_log("Parent sending SHIMEVENT_GETPERSONANAME.\n");
writeString(fd, SHIMEVENT_GETPERSONANAME, GSteamFriends->GetPersonaName());
break;
case SHIMCMD_GETCURRENTGAMELANGUAGE:
dbgpipe("Parent sending SHIMEVENT_GETCURRENTGAMELANGUAGE.\n");
SDL_log("Parent sending SHIMEVENT_GETCURRENTGAMELANGUAGE.\n");
writeString(fd, SHIMEVENT_GETCURRENTGAMELANGUAGE, GSteamApps->GetCurrentGameLanguage());
break;
} // switch
@ -642,7 +629,7 @@ static int mainline(void){
PipeType pipeChildWrite = NULLPIPE;
ProcessType childPid;
dbgpipe("Parent starting mainline.\n");
SDL_log("Parent starting mainline.\n");
if (!createPipes(&pipeParentRead, &pipeParentWrite, &pipeChildRead, &pipeChildWrite))
fail("Failed to create application pipes");
@ -658,13 +645,13 @@ static int mainline(void){
closePipe(pipeChildWrite);
pipeChildRead = pipeChildWrite = NULLPIPE;
dbgpipe("Parent in command processing loop.\n");
SDL_log("Parent in command processing loop.\n");
// Now, we block for instructions until the pipe fails (child closed it or
// terminated/crashed).
processCommands(pipeParentRead, pipeParentWrite);
dbgpipe("Parent shutting down.\n");
SDL_log("Parent shutting down.\n");
// Close our ends of the pipes.
writeBye(pipeParentWrite);
@ -673,12 +660,12 @@ static int mainline(void){
deinitSteamworks();
dbgpipe("Parent waiting on child process.\n");
SDL_log("Parent waiting on child process.\n");
// Wait for the child to terminate, close the child process handles.
const int retval = closeProcess(&childPid);
dbgpipe("Parent exiting mainline (child exit code %d).\n", retval);
SDL_log("Parent exiting mainline (child exit code %d).\n", retval);
return retval;
} // mainline