Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 348a82b

Browse files
committed
linux compiles I guess
1 parent e289db4 commit 348a82b

File tree

8 files changed

+35
-19
lines changed

8 files changed

+35
-19
lines changed

src/core/byond_functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#include "byond_functions.inl"
44

55
#define RELATIVE_CALL_RESOLVE(ptr) ((void*)((unsigned int)ptr + 4 + *((unsigned int*)ptr)))
6-
#define RELATIVE_CALL_SET(ptr, target) (int*)ptr = (unsigned int)(target) - 4 - (unsigned int)ptr
6+
#define RELATIVE_CALL_SET(ptr, target) *(unsigned int*)ptr = (unsigned int)(target) - 4 - (unsigned int)ptr

src/core/byond_structures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#else
1212
#define REGPARM3 __attribute__((regparm(3)))
1313
#define REGPARM2 __attribute__((regparm(2)))
14+
#define FASTCALL_THIS void* this_
1415
#define PASS_FASTCALL_THIS this_
1516
#endif
1617

src/demo_writer/demo_writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ HOOK_DEF(void, SpliceAppearance)(FASTCALL_THIS, int appearance) {
8181
#ifdef _WIN32
8282
HOOK_DEF(void _fastcall, DelFilter)(FASTCALL_THIS, int id) {
8383
#else
84-
HOOK_DEF(void, DelFilter)(FASTCALL_THIS_, int id) {
84+
HOOK_DEF(void, DelFilter)(FASTCALL_THIS, int id) {
8585
#endif
8686
get_demo_id_flags(id).filter_written = false;
8787
oDelFilter(PASS_FASTCALL_THIS, id);

src/demo_writer/state_tracking.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ struct alignas(1) DemoWriterIdFlags {
1717
};
1818
unsigned char byte = 0;
1919
};
20-
template<class T> inline bool get_written();
21-
template<> inline bool get_written<Obj>() { return obj_written; }
22-
template<> inline bool get_written<Mob>() { return mob_written; }
23-
template<> inline bool get_written<Turf>() { return turf_written; }
24-
template<> inline bool get_written<ImageOverlay> () { return image_written; }
20+
template<typename T> inline bool get_written();
2521

26-
template<class T> inline void set_written(bool f);
27-
template<> inline void set_written<Obj>(bool f) { obj_written = f; }
28-
template<> inline void set_written<Mob>(bool f) { mob_written = f; }
29-
template<> inline void set_written<Turf>(bool f) { turf_written = f; }
30-
template<> inline void set_written<ImageOverlay>(bool f) { image_written = f; }
22+
template<typename T> inline void set_written(bool f);
3123
};
3224

25+
26+
template<> inline bool DemoWriterIdFlags::get_written<Obj>() { return obj_written; }
27+
template<> inline bool DemoWriterIdFlags::get_written<Mob>() { return mob_written; }
28+
template<> inline bool DemoWriterIdFlags::get_written<Turf>() { return turf_written; }
29+
template<> inline bool DemoWriterIdFlags::get_written<ImageOverlay> () { return image_written; }
30+
template<> inline void DemoWriterIdFlags::set_written<Obj>(bool f) { obj_written = f; }
31+
template<> inline void DemoWriterIdFlags::set_written<Mob>(bool f) { mob_written = f; }
32+
template<> inline void DemoWriterIdFlags::set_written<Turf>(bool f) { turf_written = f; }
33+
template<> inline void DemoWriterIdFlags::set_written<ImageOverlay>(bool f) { image_written = f; }
34+
3335
extern std::vector<DemoWriterIdFlags> demo_id_flags;
34-
DemoWriterIdFlags& get_demo_id_flags(int id);
36+
DemoWriterIdFlags& get_demo_id_flags(int id);

src/demo_writer/write_animate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ Value animate_args;
7272
Value last_animate_appearance;
7373

7474
char animate_end_trampoline[] = {
75-
0xe8, 0, 0, 0, 0,
76-
0xe9, 0, 0, 0, 0
77-
}
75+
(char)0xE8, 0, 0, 0, 0,
76+
(char)0xE9, 0, 0, 0, 0
77+
};
7878

7979
void pre_animate_hook(void *some_struct, Value args) {
8080
DecRefCount(animate_args);
@@ -146,7 +146,7 @@ void animate_hook() {
146146
IncRefCount({ APPEARANCE, {data.appearance_before} });
147147
IncRefCount({ APPEARANCE, {data.appearance_after} });
148148
animate_structs.push_back(data);
149-
}
149+
}
150150

151151
extern "C" void *subhook_unprotect(void *address, size_t size);
152152

src/demo_writer/write_objects.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ template<> struct LastListItem<Mob> {
4747
unsigned char last_see_invisible = 0;
4848
};
4949

50-
template<class Atom, unsigned char update_chunk_id, bool includes_loc = true, bool includes_stepxy = true, bool includes_mobextras = false>
50+
template<typename Atom, unsigned char update_chunk_id, bool includes_loc = true, bool includes_stepxy = true, bool includes_mobextras = false>
5151
class AtomUpdateBuffer {
5252
private:
5353
int dirty_floor = 0;
@@ -284,18 +284,23 @@ class AtomUpdateBuffer {
284284
}
285285
};
286286

287+
template<>
287288
inline int AtomUpdateBuffer<Turf, 0x2, false, false, false>::get_table_length() {
288289
return Core::turf_table->turf_count;
289290
}
291+
template<>
290292
inline int AtomUpdateBuffer<Obj, 0x3, true, true, false>::get_table_length() {
291293
return Core::obj_table->length;
292294
}
295+
template<>
293296
inline int AtomUpdateBuffer<Mob, 0x4, true, true, true>::get_table_length() {
294297
return Core::mob_table->length;
295298
}
299+
template<>
296300
inline int AtomUpdateBuffer<ImageOverlay, 0x5, true, false, false>::get_table_length() {
297301
return Core::image_table->length;
298302
}
303+
template<>
299304
inline Turf *AtomUpdateBuffer<Turf, 0x2, false, false, false>::get_element(int id) {
300305
if (id < Core::turf_table->turf_count || Core::turf_table->existence_table[id] == 0) {
301306
return nullptr;
@@ -306,30 +311,38 @@ inline Turf *AtomUpdateBuffer<Turf, 0x2, false, false, false>::get_element(int i
306311
}
307312
return ref;
308313
}
314+
template<>
309315
inline Obj* AtomUpdateBuffer<Obj, 0x3, true, true, false>::get_element(int id) {
310316
return id < Core::obj_table->length ? Core::obj_table->elements[id] : nullptr;
311317
}
318+
template<>
312319
inline Mob* AtomUpdateBuffer<Mob, 0x4, true, true, true>::get_element(int id) {
313320
return id < Core::mob_table->length ? Core::mob_table->elements[id] : nullptr;
314321
}
322+
template<>
315323
inline ImageOverlay* AtomUpdateBuffer<ImageOverlay, 0x5, true, false, false>::get_element(int id) {
316324
return id < Core::image_table->length ? Core::image_table->elements[id] : nullptr;
317325
}
326+
template<>
318327
inline int AtomUpdateBuffer<Turf, 0x2, false, false, false>::get_appearance(Turf* turf, int id) {
319328
if (id >= Core::turf_table->turf_count) return 0xFFFF;
320329
int shared_id = Core::turf_table->shared_info_id_table[id];
321330
return (*Core::turf_shared_info_table)[shared_id]->appearance;
322331
}
332+
template<>
323333
inline int AtomUpdateBuffer<Obj, 0x3, true, true, false>::get_appearance(Obj* obj, int id) {
324334
return obj ? GetAppearance({ OBJ, {id} }) : 0xFFFF;
325335
}
336+
template<>
326337
inline int AtomUpdateBuffer<Mob, 0x4, true, true, true>::get_appearance(Mob* mob, int id) {
327338
return mob ? GetAppearance({ MOB, {id} }) : 0xFFFF;
328339
}
340+
template<>
329341
inline bool AtomUpdateBuffer<Turf, 0x2, false, false, false>::does_element_exist(int id) {
330342
return true;
331343
}
332344
// Because image serves as both a temporary appearance holder and a per-client, let's only write it if it's going to serve the latter purpose
345+
template<>
333346
inline int AtomUpdateBuffer<ImageOverlay, 0x5, true, false, false>::get_appearance(ImageOverlay* image, int id) {
334347
return (image && image->loc.type != NULL_D) ? GetAppearance({ IMAGE, {id} }) : 0xFFFF;
335348
}

src/demo_writer/write_primitive.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#pragma once
21
#include "write_primitive.h"
32
#include "demo_writer.h"
43
#include "state_tracking.h"

src/demo_writer/write_primitive.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include <vector>
3+
#include <string.h>
34
#include "../core/byond_structures.h"
45

56
void write_vlq(std::vector<unsigned char>& buf, int value);

0 commit comments

Comments
 (0)