Skip to content
This repository was archived by the owner on Apr 10, 2021. It is now read-only.

Commit a0b05f2

Browse files
fix sockets breaking game
1 parent 731b6a9 commit a0b05f2

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

byond-extools/src/core/hooking.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ std::unordered_map<void*, subhook::Hook*> hooks;
1616

1717
//ExecutionContext* last_suspended_ec;
1818

19-
struct QueuedCall
20-
{
21-
Core::Proc proc;
22-
Value src;
23-
Value usr;
24-
std::vector<Value> args;
25-
};
26-
2719
std::vector<QueuedCall> queued_calls;
2820
bool calling_queue = false;
2921

byond-extools/src/core/hooking.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,25 @@
1313
typedef bool(*TopicFilter)(BSocket* socket, int socket_id);
1414
extern TopicFilter current_topic_filter;
1515

16+
namespace Core
17+
{
18+
struct Proc;
19+
}
20+
21+
struct QueuedCall
22+
{
23+
Core::Proc& proc;
24+
Value src;
25+
Value usr;
26+
std::vector<Value> args;
27+
};
28+
1629
namespace Core
1730
{
1831
void* install_hook(void* original, void* hook);
1932
void remove_hook(void* func);
2033
void remove_all_hooks();
2134
bool hook_custom_opcodes();
2235
void set_topic_filter(TopicFilter tf);
36+
//void schedule_call(Proc proc, std::vector<Value> args, Value src = Value::Null(), Value usr = Value::Null());
2337
}

byond-extools/src/datum_socket/datum_socket.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
std::unordered_map<unsigned int, std::unique_ptr<DatumSocket>> sockets;
1111
unsigned int recv_sleep_opcode = -1;
12+
std::vector<SuspendedProc*> timers_to_reset;
1213

1314
DatumSocket::DatumSocket()
1415
{
@@ -29,6 +30,7 @@ bool DatumSocket::connect(std::string addr, std::string port)
2930
bool connected = stream.connect(port.c_str(), addr.c_str());
3031
if (connected)
3132
{
33+
open = true;
3234
std::thread(&DatumSocket::recv_loop, this).detach();
3335
}
3436
return connected;
@@ -69,7 +71,7 @@ void DatumSocket::recv_loop()
6971
buffer_lock.unlock();
7072
if (data_awaiter)
7173
{
72-
data_awaiter->time_to_resume = 0;
74+
StartTiming(data_awaiter);
7375
data_awaiter = nullptr;
7476
}
7577
}
@@ -116,8 +118,7 @@ void recv_suspend(ExecutionContext* ctx)
116118
{
117119
ctx->current_opcode++;
118120
SuspendedProc* proc = Suspend(ctx, 0);
119-
proc->time_to_resume = 0x7FFFFF;
120-
StartTiming(proc);
121+
proc->time_to_resume = 1;
121122
int datum_id = ctx->constants->src.value;
122123
sockets[datum_id]->set_awaiter(proc);
123124
ctx->current_opcode--;
@@ -138,6 +139,10 @@ bool enable_sockets()
138139

139140
extern "C" __declspec(dllexport) const char* init_sockets(int a, const char** b)
140141
{
142+
if (!Core::initialize())
143+
{
144+
return "no";
145+
}
141146
enable_sockets();
142147
return "ok";
143148
}

byond-extools/src/datum_socket/datum_socket.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class DatumSocket
2525
std::string buffer;
2626
std::mutex buffer_lock;
2727
SuspendedProc* data_awaiter = nullptr;
28-
bool open = true;
28+
bool open = false;
2929
};
3030

31-
extern std::unordered_map<unsigned int, std::unique_ptr<DatumSocket>> sockets;
31+
extern std::unordered_map<unsigned int, std::unique_ptr<DatumSocket>> sockets;
32+
extern std::vector<SuspendedProc*> timers_to_reset;

byond-extools/src/maptick/maptick.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "maptick.h"
22
#include "../core/core.h"
33
#include <chrono>
4+
#include "../datum_socket/datum_socket.h"
45

56
//#define MAPTICK_FAST_WRITE
67

0 commit comments

Comments
 (0)