mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-03 10:23:38 +02:00
connection::senses(): Split to many smaller printfs
This commit is contained in:
parent
39b61175c1
commit
1fcd4e45b7
1 changed files with 8 additions and 11 deletions
|
@ -19,15 +19,12 @@ connection::senses(int tick_id, class agent &a)
|
||||||
assert(!negotiation);
|
assert(!negotiation);
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
snprintf(buf, sizeof(buf),
|
char *bufp = buf;
|
||||||
"tick %d\r\n"
|
bufp += snprintf(bufp, sizeof(buf) - (bufp - buf), "tick %d\r\n", tick_id);
|
||||||
"%s"
|
if (a.dead)
|
||||||
"energy %d\r\n"
|
bufp += snprintf(bufp, sizeof(buf) - (bufp - buf), "DEAD\r\n");
|
||||||
"visual %s %s %s %s %s %s %s %s" " %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s" "\r\n"
|
bufp += snprintf(bufp, sizeof(buf) - (bufp - buf), "energy %d\r\n", a.energy);
|
||||||
"\r\n",
|
bufp += snprintf(bufp, sizeof(buf) - (bufp - buf), "visual %s %s %s %s %s %s %s %s" " %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s" "\r\n",
|
||||||
tick_id,
|
|
||||||
a.dead ? "DEAD\r\n" : "",
|
|
||||||
a.energy,
|
|
||||||
|
|
||||||
a.tile->tile_in_dir(0, -1).str(),
|
a.tile->tile_in_dir(0, -1).str(),
|
||||||
a.tile->tile_in_dir(1, -1).str(),
|
a.tile->tile_in_dir(1, -1).str(),
|
||||||
|
@ -53,8 +50,8 @@ connection::senses(int tick_id, class agent &a)
|
||||||
a.tile->tile_in_dir(-2, 0).str(),
|
a.tile->tile_in_dir(-2, 0).str(),
|
||||||
a.tile->tile_in_dir(-2, -1).str(),
|
a.tile->tile_in_dir(-2, -1).str(),
|
||||||
a.tile->tile_in_dir(-2, -2).str(),
|
a.tile->tile_in_dir(-2, -2).str(),
|
||||||
a.tile->tile_in_dir(-1, -2).str()
|
a.tile->tile_in_dir(-1, -2).str());
|
||||||
);
|
bufp += snprintf(bufp, sizeof(buf) - (bufp - buf), "\r\n");
|
||||||
|
|
||||||
pthread_mutex_lock(&buf_lock);
|
pthread_mutex_lock(&buf_lock);
|
||||||
out_buf.append(buf);
|
out_buf.append(buf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue