Skip to content

Commit

Permalink
Compat with std libs
Browse files Browse the repository at this point in the history
  • Loading branch information
KionX committed Aug 4, 2023
1 parent 67917d2 commit f76bbfe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions section.ld
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ SECTIONS {
*(.eh_frame*)
*(.ctors)
*(.reloc)
*(.idata*)
}
}
3 changes: 1 addition & 2 deletions section/SimGetCommandQueue.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "include/moho.h"
#include "include/LuaAPI.h"

void __thiscall SimGetCommandQueueInsert(LuaObject *this_, LuaObject *obj)
{
Expand All @@ -11,7 +10,7 @@ void __thiscall SimGetCommandQueueInsert(LuaObject *this_, LuaObject *obj)
auto targetId = *reinterpret_cast<unsigned long*>(unitCmd + 0xA0);
if (targetId != 0xF0000000) {
char buf[16];
sprintf_s(buf, sizeof(buf), "%d", targetId); //like game doing entityId with std::string
FAsprintf_s(buf, sizeof(buf), "%d", targetId); //like game doing entityId with std::string
obj->SetString("targetId", buf);
}
auto v3 = *reinterpret_cast<uintptr_t*>(unitCmd + 0x60);
Expand Down
2 changes: 1 addition & 1 deletion section/SimGetDepositsAroundPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int SimGetDepositsAroundPoint(lua_State *L) {
lua_push(L, "X2", deposit->X2);
lua_push(L, "Z2", deposit->Z2);
lua_push(L, "Type", deposit->Type);
lua_push(L, "Dist", sqrtf(dist));
lua_push(L, "Dist", FAsqrtf(dist));
lua_settable(L, -3);
}
return 1;
Expand Down
22 changes: 11 additions & 11 deletions section/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ FDecl(0x937C30, SpewF, int (*)(const char *fmt, ...))
FDecl(0x41C990, ConsoleLogF, int (*)(const char *fmt, ...))
FDecl(0xA9B4E6, FileWrite, int (*)(int fileIndex, const char *str, int strlen)) //index 3 is log.
FDecl(0xA825B9, shi_new, void* (*)(size_t size))
FDecl(0x957B00, realloc, void* (*)(void *ptr, size_t new_size))
FDecl(0x958B20, malloc, void* (*)(size_t size))
FDecl(0x958C40, free, void (*)(void *ptr))
FDecl(0x957EA0, msize, size_t (*)(void *memblock))
FDecl(0x957AB0, calloc, void* (*)(size_t num, size_t size))
FDecl(0xA89110, memset, void* (*)(void *dest, int ch, size_t count))
FDecl(0xA89190, memcpy, void* (*)(void *dest, const void *src, size_t count))
FDecl(0x452FC0, sqrtf, float (*)(float arg))
FDecl(0xA94450, strlen, size_t (*)(const char *str))
FDecl(0xAA549E, strcmp, int (*)(const char *str1, const char *str2))
FDecl(0xA82F32, sprintf_s, int (*)(char *Buffer, size_t BufferCount, const char *Format, ...))
FDecl(0x957B00, FArealloc, void* (*)(void *ptr, size_t new_size))
FDecl(0x958B20, FAmalloc, void* (*)(size_t size))
FDecl(0x958C40, FAfree, void (*)(void *ptr))
FDecl(0x957EA0, FAmsize, size_t (*)(void *memblock))
FDecl(0x957AB0, FAcalloc, void* (*)(size_t num, size_t size))
FDecl(0xA89110, FAmemset, void* (*)(void *dest, int ch, size_t count))
FDecl(0xA89190, FAmemcpy, void* (*)(void *dest, const void *src, size_t count))
FDecl(0x452FC0, FAsqrtf, float (*)(float arg))
FDecl(0xA94450, FAstrlen, size_t (*)(const char *str))
FDecl(0xAA549E, FAstrcmp, int (*)(const char *str1, const char *str2))
FDecl(0xA82F32, FAsprintf_s, int (*)(char *Buffer, size_t BufferCount, const char *Format, ...))

FDecl(0x405550, InitString, __thiscall void (*)(void *this_, const char *str))
FDecl(0x4059E0, AssignString, __thiscall void (*)(void *this_, const char *str, size_t size))
Expand Down

0 comments on commit f76bbfe

Please sign in to comment.