aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--media/Test sim/objects/onefang%27s%20test%20bed.5cb927d5-1304-4f1a-9947-308251ef2df0/~memory.lsl6
-rw-r--r--src/love/love.c82
2 files changed, 85 insertions, 3 deletions
diff --git a/media/Test sim/objects/onefang%27s%20test%20bed.5cb927d5-1304-4f1a-9947-308251ef2df0/~memory.lsl b/media/Test sim/objects/onefang%27s%20test%20bed.5cb927d5-1304-4f1a-9947-308251ef2df0/~memory.lsl
index 9133506..17f777d 100644
--- a/media/Test sim/objects/onefang%27s%20test%20bed.5cb927d5-1304-4f1a-9947-308251ef2df0/~memory.lsl
+++ b/media/Test sim/objects/onefang%27s%20test%20bed.5cb927d5-1304-4f1a-9947-308251ef2df0/~memory.lsl
@@ -44,7 +44,7 @@ integer myListFind(list a, string b) {
44 return x; 44 return x;
45 } 45 }
46 } 46 }
47 47
48 return -1; 48 return -1;
49} 49}
50 50
@@ -83,7 +83,7 @@ string adjust(integer doOffset, vector pos, vector erot, vector amt) {
83 pos += amt/100.; 83 pos += amt/100.;
84 return (vround(pos) + " " + vround(erot)); 84 return (vround(pos) + " " + vround(erot));
85 } 85 }
86 86
87 rotation amount = llEuler2Rot(amt * DEG_TO_RAD); 87 rotation amount = llEuler2Rot(amt * DEG_TO_RAD);
88 erot *= DEG_TO_RAD; 88 erot *= DEG_TO_RAD;
89 89
@@ -167,7 +167,7 @@ add_pose(string name, string data) {
167 if (ix != -1) { 167 if (ix != -1) {
168 llOwnerSay("===> WARNING: Multiple .POSITIONS* entries for '" + name + "'"); 168 llOwnerSay("===> WARNING: Multiple .POSITIONS* entries for '" + name + "'");
169 } else { 169 } else {
170 Poses += (list) name; 170 Poses += name;
171 ix = ++PosCount; 171 ix = ++PosCount;
172 } 172 }
173 store_pose(data, ix-1); 173 store_pose(data, ix-1);
diff --git a/src/love/love.c b/src/love/love.c
index dc524d8..db4c557 100644
--- a/src/love/love.c
+++ b/src/love/love.c
@@ -12,6 +12,9 @@ Dedicated to my girl Boots, coz she means the world to me.
12#include <Edje.h> 12#include <Edje.h>
13 13
14#include <unistd.h> 14#include <unistd.h>
15#include <sys/types.h>
16#include <sys/stat.h>
17#include <fcntl.h>
15 18
16#include "LumbrJack.h" 19#include "LumbrJack.h"
17#include "Runnr.h" 20#include "Runnr.h"
@@ -196,6 +199,26 @@ static Eina_Bool _addLuaSL(void *data, int type, Ecore_Con_Event_Server_Add *ev)
196 return ECORE_CALLBACK_RENEW; 199 return ECORE_CALLBACK_RENEW;
197} 200}
198 201
202
203// Borrowed from toybox, though it's real slow.
204// TODO - Replace this quick and dirty llGetNotecardLine() with something using mmap and cached files that assumes more lines will be read soon.
205char *get_rawline(int fd, long *plen, char end)
206{
207 char c, *buf = NULL;
208 long len = 0;
209
210 for (;;) {
211 if (1>read(fd, &c, 1)) break;
212 if (!(len & 63)) buf=realloc(buf, len+65);
213 if ((buf[len++]=c) == end) break;
214 }
215 if (buf) buf[len]=0;
216 if (plen) *plen = len;
217
218 return buf;
219}
220
221
199static Eina_Bool _dataLuaSL(void *data, int type, Ecore_Con_Event_Server_Data *ev) 222static Eina_Bool _dataLuaSL(void *data, int type, Ecore_Con_Event_Server_Data *ev)
200{ 223{
201 gameGlobals *ourGlobals = data; 224 gameGlobals *ourGlobals = data;
@@ -361,6 +384,65 @@ static Eina_Bool _dataLuaSL(void *data, int type, Ecore_Con_Event_Server_Data *e
361 sendForth(ourGlobals->serverLuaSL, me->SID, "events.link_message%s", &command[15]); 384 sendForth(ourGlobals->serverLuaSL, me->SID, "events.link_message%s", &command[15]);
362 } 385 }
363 } 386 }
387 else if (0 == strncmp(command, "llGetNotecardLine(", 18))
388 {
389 char *notecard, *temp, *line, key[PATH_MAX];
390 int lineNo, fd;
391
392 strcpy(buf, &command[19]);
393 notecard = buf;
394 temp = notecard;
395 while ('"' != temp[0])
396 temp++;
397 temp[0] = '\0';
398 while (',' != temp[0])
399 temp++;
400 while (' ' != temp[0])
401 temp++;
402 line = temp;
403 while (')' != temp[0])
404 temp++;
405 temp[0] = '\0';
406 lineNo = atoi(line);
407 snprintf(key, sizeof(key), "%s/Test sim/objects/onefang%%27s%%20test%%20bed.5cb927d5-1304-4f1a-9947-308251ef2df0/%s", PACKAGE_DATA_DIR, notecard);
408
409 fd = open(key, O_RDONLY);
410 if (-1 != fd)
411 {
412 Eina_Iterator *scripts;
413 script *me;
414 long len;
415
416 temp = NULL;
417 do
418 {
419 temp = get_rawline(fd, &len, '\n');
420 if (temp)
421 {
422 if (temp[len - 1] == '\n')
423 temp[--len] = '\0';
424 }
425 } while (temp && (0 < lineNo--));
426
427 sprintf(key, "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random());
428 sendForth(ourGlobals->serverLuaSL, SID, "return \"%s\"", key);
429
430 // TODO - For now, just send it to everyone.
431 scripts = eina_hash_iterator_data_new(ourGlobals->scripts);
432 while(eina_iterator_next(scripts, (void **) &me))
433 {
434 if (temp)
435 {
436 sendForth(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", \"%s\")", key, temp);
437 }
438 else
439 sendForth(ourGlobals->serverLuaSL, me->SID, "events.dataserver(\"%s\", [[\\n\\n\\n]])", key);
440 }
441
442 close(fd);
443 }
444
445 }
364 else 446 else
365 PI("Script %s sent command %s", SID, command); 447 PI("Script %s sent command %s", SID, command);
366 } 448 }