diff options
author | Tim Malte Gräfje <Tim.Graefje@gmx.de> | 2013-08-04 13:01:20 +0200 |
---|---|---|
committer | Tim Malte Gräfje <Tim.Graefje@gmx.de> | 2013-08-04 13:01:20 +0200 |
commit | 0259cb0194901c7d85ea7cd7749fdeed5a6d3761 (patch) | |
tree | 16bc2ad99581b47f6524c2e4da6a6380599bd0cf /testing/nTox_win32.c | |
parent | 170af10204d2698374725f10195eab281551d9a2 (diff) |
added fix in nTox_win32.c
Diffstat (limited to 'testing/nTox_win32.c')
-rw-r--r-- | testing/nTox_win32.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c index 5501ecf5..f3c7a188 100644 --- a/testing/nTox_win32.c +++ b/testing/nTox_win32.c | |||
@@ -26,7 +26,12 @@ | |||
26 | 26 | ||
27 | #include <process.h> | 27 | #include <process.h> |
28 | 28 | ||
29 | uint8_t pending_requests[256][CLIENT_ID_SIZE]; | 29 | typedef struct { |
30 | uint8_t id[CLIENT_ID_SIZE]; | ||
31 | uint8_t accepted; | ||
32 | } Friend_request; | ||
33 | |||
34 | Friend_request pending_requests[256]; | ||
30 | uint8_t num_requests = 0; | 35 | uint8_t num_requests = 0; |
31 | uint32_t maxnumfriends; | 36 | uint32_t maxnumfriends; |
32 | 37 | ||
@@ -51,7 +56,8 @@ void print_request(uint8_t *public_key, uint8_t *data, uint16_t length) | |||
51 | char numchar[100]; | 56 | char numchar[100]; |
52 | sprintf(numchar, "\n[i] accept request with /a %u\n\n", num_requests); | 57 | sprintf(numchar, "\n[i] accept request with /a %u\n\n", num_requests); |
53 | printf(numchar); | 58 | printf(numchar); |
54 | memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE); | 59 | memcpy(pending_requests[num_requests].id, public_key, CLIENT_ID_SIZE); |
60 | pending_requests[num_requests].accepted = 0; | ||
55 | ++num_requests; | 61 | ++num_requests; |
56 | } | 62 | } |
57 | 63 | ||
@@ -287,10 +293,21 @@ void accept_friend_request() | |||
287 | friend_request_received = 0; | 293 | friend_request_received = 0; |
288 | uint8_t numf = atoi(line + 3); | 294 | uint8_t numf = atoi(line + 3); |
289 | char numchar[100]; | 295 | char numchar[100]; |
290 | int num = m_addfriend_norequest(pending_requests[numf]); | 296 | if (numf >= num_requests || pending_requests[numf].accepted) { |
291 | sprintf(numchar, "\n[i] Added friendnumber: %d\n\n", num); | 297 | sprintf(numchar, "\n[i] you either didn't receive that request or you already accepted it"); |
292 | printf(numchar); | 298 | printf(numchar); |
293 | ++maxnumfriends; | 299 | } else { |
300 | int num = m_addfriend_norequest(pending_requests[numf].id); | ||
301 | if (num != -1) { | ||
302 | pending_requests[numf].accepted = 1; | ||
303 | sprintf(numchar, "\n[i] Added friendnumber: %d\n\n", num); | ||
304 | printf(numchar); | ||
305 | ++maxnumfriends; | ||
306 | } else { | ||
307 | sprintf(numchar, "[i] failed to add friend"); | ||
308 | printf(numchar); | ||
309 | } | ||
310 | } | ||
294 | } | 311 | } |
295 | 312 | ||
296 | void line_eval(char* line) | 313 | void line_eval(char* line) |