diff options
author | David Walter Seikel | 2016-01-17 17:03:56 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-01-17 17:03:56 +1000 |
commit | 4e2030607818d83b4e5987df2d889f64f8dce3b3 (patch) | |
tree | 370625391b847bed4fa05c888448d1b9a18895b6 /src/love | |
parent | Bunch of debuggingnesses. (diff) | |
download | SledjHamr-4e2030607818d83b4e5987df2d889f64f8dce3b3.zip SledjHamr-4e2030607818d83b4e5987df2d889f64f8dce3b3.tar.gz SledjHamr-4e2030607818d83b4e5987df2d889f64f8dce3b3.tar.bz2 SledjHamr-4e2030607818d83b4e5987df2d889f64f8dce3b3.tar.xz |
Unify the message sending code a bit.
Diffstat (limited to '')
-rw-r--r-- | src/love/love.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/love/love.c b/src/love/love.c index f8ce522..e6f5b6e 100644 --- a/src/love/love.c +++ b/src/love/love.c | |||
@@ -142,7 +142,7 @@ static void dirList_compile(const char *name, const char *path, void *data) | |||
142 | snprintf(me->SID, sizeof(me->SID), FAKE_UUID); | 142 | snprintf(me->SID, sizeof(me->SID), FAKE_UUID); |
143 | snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); | 143 | snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); |
144 | eina_hash_add(ourGlobals->scripts, me->SID, me); | 144 | eina_hash_add(ourGlobals->scripts, me->SID, me); |
145 | sendForth(ourGlobals->serverLuaSL, me->SID, "compile(%s)", me->fileName); | 145 | send2(ourGlobals->serverLuaSL, me->SID, "compile(%s)", me->fileName); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | } | 148 | } |
@@ -278,47 +278,47 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
278 | } | 278 | } |
279 | } | 279 | } |
280 | //PD("About to run %s", me->fileName); | 280 | //PD("About to run %s", me->fileName); |
281 | sendForth(ourGlobals->serverLuaSL, SID, "run(%s)", me->fileName); | 281 | send2(ourGlobals->serverLuaSL, SID, "run(%s)", me->fileName); |
282 | } | 282 | } |
283 | else | 283 | else |
284 | { | 284 | { |
285 | //PD("FAKING (maybe) %s", command); | 285 | //PD("FAKING (maybe) %s", command); |
286 | // Send back some random or fixed values for testing. | 286 | // Send back some random or fixed values for testing. |
287 | if (0 == strcmp(command, "llGetKey()")) | 287 | if (0 == strcmp(command, "llGetKey()")) |
288 | sendForth(ourGlobals->serverLuaSL, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); | 288 | send2(ourGlobals->serverLuaSL, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); |
289 | else if (0 == strcmp(command, "llGetOwner()")) | 289 | else if (0 == strcmp(command, "llGetOwner()")) |
290 | sendForth(ourGlobals->serverLuaSL, SID, "return \"%s\"", ownerKey); | 290 | send2(ourGlobals->serverLuaSL, SID, "return \"%s\"", ownerKey); |
291 | else if (0 == strcmp(command, "llGetPermissionsKey()")) | 291 | else if (0 == strcmp(command, "llGetPermissionsKey()")) |
292 | sendForth(ourGlobals->serverLuaSL, SID, "return \"%s\"", ownerKey); | 292 | send2(ourGlobals->serverLuaSL, SID, "return \"%s\"", ownerKey); |
293 | else if (0 == strncmp(command, "llRequestPermissions(", 21)) | 293 | else if (0 == strncmp(command, "llRequestPermissions(", 21)) |
294 | PI("Faked %s", command); | 294 | PI("Faked %s", command); |
295 | else if (0 == strcmp(command, "llGetPos()")) | 295 | else if (0 == strcmp(command, "llGetPos()")) |
296 | sendForth(ourGlobals->serverLuaSL, SID, "return {x=128.0, y=128.0, z=128.0}"); | 296 | send2(ourGlobals->serverLuaSL, SID, "return {x=128.0, y=128.0, z=128.0}"); |
297 | else if (0 == strcmp(command, "llGetRot()")) | 297 | else if (0 == strcmp(command, "llGetRot()")) |
298 | sendForth(ourGlobals->serverLuaSL, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); | 298 | send2(ourGlobals->serverLuaSL, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); |
299 | else if (0 == strcmp(command, "llGetFreeMemory()")) | 299 | else if (0 == strcmp(command, "llGetFreeMemory()")) |
300 | sendForth(ourGlobals->serverLuaSL, SID, "return 654321"); | 300 | send2(ourGlobals->serverLuaSL, SID, "return 654321"); |
301 | else if (0 == strcmp(command, "llGetObjectDesc()")) | 301 | else if (0 == strcmp(command, "llGetObjectDesc()")) |
302 | sendForth(ourGlobals->serverLuaSL, SID, "return \"\""); | 302 | send2(ourGlobals->serverLuaSL, SID, "return \"\""); |
303 | else if (0 == strncmp(command, "llGetAlpha(", 11)) | 303 | else if (0 == strncmp(command, "llGetAlpha(", 11)) |
304 | sendForth(ourGlobals->serverLuaSL, SID, "return 1.0"); | 304 | send2(ourGlobals->serverLuaSL, SID, "return 1.0"); |
305 | else if (0 == strcmp(command, "llGetInventoryNumber(7)")) | 305 | else if (0 == strcmp(command, "llGetInventoryNumber(7)")) |
306 | sendForth(ourGlobals->serverLuaSL, SID, "return 3"); | 306 | send2(ourGlobals->serverLuaSL, SID, "return 3"); |
307 | else if (0 == strcmp(command, "llGetLinkNumber()")) | 307 | else if (0 == strcmp(command, "llGetLinkNumber()")) |
308 | sendForth(ourGlobals->serverLuaSL, SID, "return 1"); | 308 | send2(ourGlobals->serverLuaSL, SID, "return 1"); |
309 | else if (0 == strcmp(command, "llGetInventoryName(7, 2)")) | 309 | else if (0 == strcmp(command, "llGetInventoryName(7, 2)")) |
310 | sendForth(ourGlobals->serverLuaSL, SID, "return \".readme\""); | 310 | send2(ourGlobals->serverLuaSL, SID, "return \".readme\""); |
311 | else if (0 == strcmp(command, "llGetInventoryName(7, 1)")) | 311 | else if (0 == strcmp(command, "llGetInventoryName(7, 1)")) |
312 | sendForth(ourGlobals->serverLuaSL, SID, "return \".POSITIONS\""); | 312 | send2(ourGlobals->serverLuaSL, SID, "return \".POSITIONS\""); |
313 | else if (0 == strcmp(command, "llGetInventoryName(7, 0)")) | 313 | else if (0 == strcmp(command, "llGetInventoryName(7, 0)")) |
314 | sendForth(ourGlobals->serverLuaSL, SID, "return \".MENUITEMS\""); | 314 | send2(ourGlobals->serverLuaSL, SID, "return \".MENUITEMS\""); |
315 | else if (0 == strncmp(command, "llListen(", 9)) | 315 | else if (0 == strncmp(command, "llListen(", 9)) |
316 | { | 316 | { |
317 | PI("Faked %s", command); | 317 | PI("Faked %s", command); |
318 | sendForth(ourGlobals->serverLuaSL, SID, "return %d", random()); | 318 | send2(ourGlobals->serverLuaSL, SID, "return %d", random()); |
319 | } | 319 | } |
320 | else if (0 == strncmp(command, "llSameGroup(", 12)) | 320 | else if (0 == strncmp(command, "llSameGroup(", 12)) |
321 | sendForth(ourGlobals->serverLuaSL, SID, "return true"); | 321 | send2(ourGlobals->serverLuaSL, SID, "return true"); |
322 | else if (0 == strncmp(command, "llKey2Name(", 11)) | 322 | else if (0 == strncmp(command, "llKey2Name(", 11)) |
323 | { | 323 | { |
324 | char *temp; | 324 | char *temp; |
@@ -334,7 +334,7 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
334 | temp = "Unknown User"; | 334 | temp = "Unknown User"; |
335 | // TODO - Sanitize the name, no telling what weird shit people put in their names. | 335 | // TODO - Sanitize the name, no telling what weird shit people put in their names. |
336 | snprintf(buf, sizeof(buf), "return \"%s\"", temp); | 336 | snprintf(buf, sizeof(buf), "return \"%s\"", temp); |
337 | sendForth(ourGlobals->serverLuaSL, SID, buf); | 337 | send2(ourGlobals->serverLuaSL, SID, buf); |
338 | } | 338 | } |
339 | // Send "back" stuff on to the one and only client. | 339 | // Send "back" stuff on to the one and only client. |
340 | // TODO - All of these output functions should just use one thing to append stuff to either local or an IM tab. | 340 | // TODO - All of these output functions should just use one thing to append stuff to either local or an IM tab. |
@@ -344,34 +344,34 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
344 | // Dialogs, notifications, and other stuff goes through some other functions. | 344 | // Dialogs, notifications, and other stuff goes through some other functions. |
345 | else if (0 == strncmp(command, "llOwnerSay(", 11)) | 345 | else if (0 == strncmp(command, "llOwnerSay(", 11)) |
346 | { | 346 | { |
347 | if (ourGlobals->client) sendBack(ourGlobals->client, SID, command); | 347 | if (ourGlobals->client) send2(ourGlobals->client, SID, command); |
348 | else PW("No where to send %s", command); | 348 | else PW("No where to send %s", command); |
349 | } | 349 | } |
350 | else if (0 == strncmp(command, "llWhisper(", 10)) | 350 | else if (0 == strncmp(command, "llWhisper(", 10)) |
351 | { | 351 | { |
352 | if (ourGlobals->client) sendBack(ourGlobals->client, SID, command); | 352 | if (ourGlobals->client) send2(ourGlobals->client, SID, command); |
353 | else PW("No where to send %s", command); | 353 | else PW("No where to send %s", command); |
354 | } | 354 | } |
355 | else if (0 == strncmp(command, "llRegionSay(", 12)) | 355 | else if (0 == strncmp(command, "llRegionSay(", 12)) |
356 | { | 356 | { |
357 | if (ourGlobals->client) sendBack(ourGlobals->client, SID, command); | 357 | if (ourGlobals->client) send2(ourGlobals->client, SID, command); |
358 | else PW("No where to send %s", command); | 358 | else PW("No where to send %s", command); |
359 | } | 359 | } |
360 | else if (0 == strncmp(command, "llSay(", 6)) | 360 | else if (0 == strncmp(command, "llSay(", 6)) |
361 | { | 361 | { |
362 | if (ourGlobals->client) sendBack(ourGlobals->client, SID, command); | 362 | if (ourGlobals->client) send2(ourGlobals->client, SID, command); |
363 | else PW("No where to send %s", command); | 363 | else PW("No where to send %s", command); |
364 | } | 364 | } |
365 | else if (0 == strncmp(command, "llShout(", 8)) | 365 | else if (0 == strncmp(command, "llShout(", 8)) |
366 | { | 366 | { |
367 | if (ourGlobals->client) sendBack(ourGlobals->client, SID, command); | 367 | if (ourGlobals->client) send2(ourGlobals->client, SID, command); |
368 | else PW("No where to send %s", command); | 368 | else PW("No where to send %s", command); |
369 | // TODO - Temporary so we have a place to log stuff from LSL. | 369 | // TODO - Temporary so we have a place to log stuff from LSL. |
370 | PD("SHOUTING %s", command); | 370 | PD("SHOUTING %s", command); |
371 | } | 371 | } |
372 | else if (0 == strncmp(command, "llDialog(", 9)) | 372 | else if (0 == strncmp(command, "llDialog(", 9)) |
373 | { | 373 | { |
374 | if (ourGlobals->client) sendBack(ourGlobals->client, SID, command); | 374 | if (ourGlobals->client) send2(ourGlobals->client, SID, command); |
375 | else PW("No where to send %s", command); | 375 | else PW("No where to send %s", command); |
376 | } | 376 | } |
377 | else if (0 == strncmp(command, "llMessageLinked(", 16)) | 377 | else if (0 == strncmp(command, "llMessageLinked(", 16)) |
@@ -383,7 +383,7 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
383 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); | 383 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); |
384 | while(eina_iterator_next(scripts, (void **) &me)) | 384 | while(eina_iterator_next(scripts, (void **) &me)) |
385 | { | 385 | { |
386 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.link_message%s", &command[15]); | 386 | send2(ourGlobals->serverLuaSL, me->SID, "events.link_message%s", &command[15]); |
387 | } | 387 | } |
388 | eina_iterator_free(scripts); | 388 | eina_iterator_free(scripts); |
389 | } | 389 | } |
@@ -429,7 +429,7 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
429 | } while (temp && (0 < lineNo--)); | 429 | } while (temp && (0 < lineNo--)); |
430 | 430 | ||
431 | sprintf(key, FAKE_UUID); | 431 | sprintf(key, FAKE_UUID); |
432 | sendForth(ourGlobals->serverLuaSL, SID, "return \"%s\"", key); | 432 | send2(ourGlobals->serverLuaSL, SID, "return \"%s\"", key); |
433 | 433 | ||
434 | // TODO - For now, just send it to everyone. | 434 | // TODO - For now, just send it to everyone. |
435 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); | 435 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); |
@@ -449,10 +449,10 @@ static Eina_Bool LuaSLParser(void *data, Connection *conn, char *SID, char *comm | |||
449 | buf2[j++] = '\\'; | 449 | buf2[j++] = '\\'; |
450 | buf2[j++] = temp[i]; | 450 | buf2[j++] = temp[i]; |
451 | } | 451 | } |
452 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", '%s')", key, buf2); | 452 | send2(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", '%s')", key, buf2); |
453 | } | 453 | } |
454 | else | 454 | else |
455 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \"EndOfFuckingAround\")", key); | 455 | send2(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \"EndOfFuckingAround\")", key); |
456 | } | 456 | } |
457 | eina_iterator_free(scripts); | 457 | eina_iterator_free(scripts); |
458 | free(temp); | 458 | free(temp); |
@@ -492,7 +492,7 @@ static Eina_Bool _addClient(void *data, int type, Ecore_Con_Event_Client_Add *ev | |||
492 | if (ourGlobals->client) | 492 | if (ourGlobals->client) |
493 | { | 493 | { |
494 | // TODO - Sending the currently hard coded ownerKey here, should actually deal with logging in / hypergrid TP style things instead. | 494 | // TODO - Sending the currently hard coded ownerKey here, should actually deal with logging in / hypergrid TP style things instead. |
495 | sendBack(ourGlobals->client, ownerKey, "loadSim('file://%s/Test%%20sim')", prefix_data_get()); | 495 | send2(ourGlobals->client, ownerKey, "loadSim('file://%s/Test%%20sim')", prefix_data_get()); |
496 | } | 496 | } |
497 | 497 | ||
498 | return ECORE_CALLBACK_RENEW; | 498 | return ECORE_CALLBACK_RENEW; |
@@ -511,9 +511,9 @@ static Eina_Bool clientParser(void *data, Connection *conn, char *SID, char *com | |||
511 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); | 511 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); |
512 | while(eina_iterator_next(scripts, (void **) &me)) | 512 | while(eina_iterator_next(scripts, (void **) &me)) |
513 | { | 513 | { |
514 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); | 514 | send2(ourGlobals->serverLuaSL, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); |
515 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.detectedNames({\"%s\"})", ownerName); | 515 | send2(ourGlobals->serverLuaSL, me->SID, "events.detectedNames({\"%s\"})", ownerName); |
516 | sendForth(ourGlobals->serverLuaSL, me->SID, "events.touch_start(1)"); | 516 | send2(ourGlobals->serverLuaSL, me->SID, "events.touch_start(1)"); |
517 | } | 517 | } |
518 | eina_iterator_free(scripts); | 518 | eina_iterator_free(scripts); |
519 | } | 519 | } |
@@ -528,7 +528,7 @@ static Eina_Bool clientParser(void *data, Connection *conn, char *SID, char *com | |||
528 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); | 528 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); |
529 | while(eina_iterator_next(scripts, (void **) &me)) | 529 | while(eina_iterator_next(scripts, (void **) &me)) |
530 | { | 530 | { |
531 | sendForth(ourGlobals->serverLuaSL, me->SID, buf); | 531 | send2(ourGlobals->serverLuaSL, me->SID, buf); |
532 | } | 532 | } |
533 | eina_iterator_free(scripts); | 533 | eina_iterator_free(scripts); |
534 | } | 534 | } |
@@ -543,7 +543,7 @@ static Eina_Bool _delClient(void *data, int type, Ecore_Con_Event_Client_Del *ev | |||
543 | gameGlobals *ourGlobals = data; | 543 | gameGlobals *ourGlobals = data; |
544 | 544 | ||
545 | // TODO - I could coax this into something generic, maybe. | 545 | // TODO - I could coax this into something generic, maybe. |
546 | sendForth(ourGlobals->serverLuaSL, ownerKey, "exit()"); | 546 | send2(ourGlobals->serverLuaSL, ownerKey, "exit()"); |
547 | 547 | ||
548 | return ECORE_CALLBACK_RENEW; | 548 | return ECORE_CALLBACK_RENEW; |
549 | } | 549 | } |