Skip to content

Commit

Permalink
gpx.patch 17.01.2024
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Jan 17, 2024
1 parent d1bbd7e commit b7c3fb3
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Source/Game/GameContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ void findGameContent() {
std::set<std::string> scannedPaths;
for (std::string rootPathStr : paths) {
if (rootPathStr.empty()) continue;
#ifdef GPX
if (rootPathStr == "/") {
continue;
}
#endif
terminate_with_char(rootPathStr, PATH_SEP);
scannedPaths.insert(rootPathStr);
std::filesystem::path rootPath = std::filesystem::u8path(rootPathStr);
Expand Down
18 changes: 18 additions & 0 deletions Source/Game/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include <SDL_image.h>
#include <SDL_vulkan.h>

#ifdef GPX
#include <c/gamepix.h>
#endif

#ifdef _WIN32
#include <commdlg.h>
#endif
Expand Down Expand Up @@ -895,6 +899,12 @@ char* alloc_exec_arg_string(std::string arg, bool wrap_spaces) {

int SDL_main(int argc, char *argv[])
{
#if defined(GPX) && defined(EMSCRIPTEN)
std::filesystem::current_path("/game");
SDL_SetHint("SDL_EMSCRIPTEN_ASYNCIFY", "0");
SDL_SetHint("SDL_HINT_TOUCH_MOUSE_EVENTS", "1");
SDL_SetHint("SDL_HINT_MOUSE_TOUCH_EVENTS", "0");
#endif
//Show help if requested
for(int i = 0; i < argc; i ++) {
std::string arg = string_to_lower(argv[i]);
Expand Down Expand Up @@ -1001,6 +1011,14 @@ int SDL_main(int argc, char *argv[])
WaitMessage();
#endif
}

#ifdef GPX
gpx()->sys()->mainReady(true);
gpx()->async()->runNextTask();
#ifdef EMSCRIPTEN
emscripten_sleep(0);
#endif
#endif
}

delete runtime_object;
Expand Down
8 changes: 8 additions & 0 deletions Source/Render/sokol/SokolRenderState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "DrawBuffer.h"
#include "RenderTracker.h"

#ifdef GPX
#include <c/gamepix.h>
#endif

int cSokolRender::BeginScene() {
RenderSubmitEvent(RenderEvent::BEGIN_SCENE, ActiveScene ? "ActiveScene" : "");
MTG();
Expand Down Expand Up @@ -247,6 +251,10 @@ int cSokolRender::Flush(bool wnd) {

xassert(!activeDrawBuffer || !activeDrawBuffer->written_vertices);

#ifdef GPX
gpx()->sys()->frameReady();
#endif

return 0;
}

Expand Down
11 changes: 10 additions & 1 deletion Source/Render/src/TexLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,23 @@ bool cTexLibrary::ReLoadTexture(cTexture* Texture)
}
*/
//Get path for file and open it
std::string path = convert_path_content(Texture->GetName());
Texture->GetName();
#ifdef GPX
std::string path = Texture->GetName();
if (endsWith(path, ".avi")) {
path += "x";
}
path = convert_path_content(path);
#else
std::string path = convert_path_content(Texture->GetName());
if (path.empty()) {
path = Texture->GetName();
if (endsWith(path, ".avi") && !convert_path_content(path + "x").empty()) {
//Use AVIX if available when AVI is absent
path += "x";
}
}
#endif

cFileImage* FileImage = cFileImage::Create(path.c_str());
if(!FileImage) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Terra/procedurMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ContainerPMO::~ContainerPMO(){
void vrtMap::playPMOperation(void)
{
flag_record_operation=false;
vector<ElementPMO>::iterator p;
std::vector<ElementPMO>::iterator p;
for(p=containerPMO.begin(); p!=containerPMO.end(); p++){
ElementPMO o=*p;
switch(o.basePMO.pmoID){
Expand Down
2 changes: 1 addition & 1 deletion Source/UserInterface/GraphicsOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void GraphOptions::load(const char* sectionName, const char* iniFileName) {
resSet.emplace(false, -1, res.x, res.y, 0);
}

//Dump set into vector and order it, dont add window modes that are smaller
//Dump set into vector and order it, don't add window modes that are smaller
for (DisplayMode res : resSet) {
if (!res.fullscreen) {
if (smallest.x != 0 && smallest.x < res.x) continue;
Expand Down
15 changes: 11 additions & 4 deletions Source/UserInterface/PerimeterShellDisp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,25 @@ void CShellCursorManager::Load()
for (int i=0; i<_sqsh_cursor_count; i++) {
sqshCursor& cc = _sqsh_cursors[i];

std::string image = cc.image;
#ifdef GPX
if (endsWith(image, ".avi")) {
image += "x";
}
#endif

_c.anifile = nullptr;
_c.sx = cc.sx;
_c.sy = cc.sy;
_c.bHotspotCentered = cc.hotspot_center;
_c.texture = terVisGeneric->CreateTexture(cc.image);
_c.texture = terVisGeneric->CreateTexture(image.c_str());

//Load ANI file metadata
if (isANIFile(cc.image)) {
if (isANIFile(image.c_str())) {
_c.anifile = new ANIFile();
int err = _c.anifile->load(cc.image, false);
int err = _c.anifile->load(image.c_str(), false);
if (err) {
fprintf(stderr, "Error %d loading ANI metadata for cursor %s\n", err, cc.image);
fprintf(stderr, "Error %d loading ANI metadata for cursor %s\n", err, image.c_str());
delete _c.anifile;
_c.anifile = nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/XTool/files/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ bool scan_resource_paths(std::string destination_path, std::string source_path,
}

//Do recursive search on source path
for (const auto& entry : std::filesystem::recursive_directory_iterator(source_dir)) {
for (const auto& entry : std::filesystem::recursive_directory_iterator(source_dir, std::filesystem::directory_options::skip_permission_denied)) {
if (entry.is_regular_file() || entry.is_directory()) {
add_filesystem_entry_internal(paths, entry.path().u8string(), destination_path, source_path, scanOptions);
}
Expand Down
4 changes: 4 additions & 0 deletions Source/XTool/xerrhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ XErrorHandler::~XErrorHandler() {
}

void XErrorHandler::RedirectStdio() const {
#ifdef GPX
return;
#endif

if (log_path.empty() || check_command_line("no_console_redirect") != nullptr) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions Source/XTool/xmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ const int INT_INF = 0x7fffffff;
// give different result and cause desync on multiplayer
///////////////////////////////////////////////////////////////////////////////

#ifndef GPX
//Use gamemath instead of stdlib
#define XMATH_USE_GAMEMATH
#endif

namespace xm {
//Math functions
Expand Down

0 comments on commit b7c3fb3

Please sign in to comment.