summaryrefslogtreecommitdiff
path: root/src/proto.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-05-04 19:22:36 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-05-04 19:22:36 +0000
commit8b70ac9538f7e4da10666cfc21fd368a91a77ae3 (patch)
tree0157c0b2378e3032fa2357a6e543e3bbab03445c /src/proto.c
parent9058b5c0bfc9a05c9004cfbbcdd3bb85d80ed6fc (diff)
- oprava chyby -> client sa zrutil ak dostal packety "init" a "additem" v opacnom poradi
- oprava chyby -> item a shot ukazoval pointerom na tuxa, to znamenalo, ze ak sa tux odhlasil, tak item a shot ukazoval do uvolnenej pamate - oprava chyby -> exploziu si client pridaval sam, a este prijmal packet od servera, ze sa ma pridat explozia git-svn-id: http://opensvn.csie.org/tuxanci_ng@50 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/proto.c')
-rw-r--r--src/proto.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/proto.c b/src/proto.c
index 6cb042e..db45109 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -307,6 +307,11 @@ void proto_recv_newtux_client(char *msg)
assert( msg != NULL );
+ if( getCurrentArena() == NULL )
+ {
+ return;
+ }
+
sscanf(msg, "%s %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d",
cmd, &id, &x, &y, &status, &position, &frame, &score, name,
&myGun, &myBonus, &gun1, &gun2, &gun3, &gun4, &gun5, &gun6, &gun7, &time1, &time2);
@@ -463,17 +468,11 @@ void proto_recv_deltux_client(char *msg)
void proto_send_additem_server(int type, client_t *client, item_t *p)
{
char msg[STR_PROTO_SIZE];
- int id = -1;
assert( p != NULL );
- if( p->author != NULL )
- {
- id = p->author->id;
- }
-
sprintf(msg, "additem %d %d %d %d %d %d %d\n",
- p->id, p->type, p->x, p->y, p->count, p->frame, id);
+ p->id, p->type, p->x, p->y, p->count, p->frame, p->author_id);
proto_send(type, client, msg);
}
@@ -482,13 +481,17 @@ void proto_send_additem_server(int type, client_t *client, item_t *p)
void proto_recv_additem_client(char *msg)
{
- char term_msg[STR_SIZE];
char cmd[STR_PROTO_SIZE];
int id, type, x, y, count, frame, author_id;
item_t *item;
assert( msg != NULL );
+ if( getCurrentArena() == NULL )
+ {
+ return;
+ }
+
sscanf(msg, "%s %d %d %d %d %d %d %d", cmd, &id, &type, &x, &y, &count, &frame, &author_id);
if( ( item = getItemID(getCurrentArena()->listItem, id) ) != NULL )
@@ -497,7 +500,7 @@ void proto_recv_additem_client(char *msg)
return;
}
- item = newItem(x, y, type, getTuxID(getCurrentArena()->listTux, author_id));
+ item = newItem(x, y, type, author_id);
/*
if( isConflictWithListItem(getCurrentArena()->listItem, item->x, item->y, item->w, item->h) )
{
@@ -511,10 +514,6 @@ void proto_recv_additem_client(char *msg)
item->lastSync = getMyTime();
addList(getCurrentArena()->listItem, item);
-
- sprintf(term_msg, "in arena is new item\n");
- appendTextInTerm(term_msg);
-
}
#endif
@@ -577,17 +576,11 @@ void proto_recv_item_client(char *msg)
void proto_send_shot_server(int type, client_t *client, shot_t *p)
{
char msg[STR_PROTO_SIZE];
- int id = -1;
assert( p != NULL );
- if( p->author != NULL )
- {
- id = p->author->id;
- }
-
sprintf(msg, "shot %d %d %d %d %d %d %d %d %d\n",
- p->id, p->x, p->y, p->px, p->py, p->position, p->gun, id, p->isCanKillAuthor);
+ p->id, p->x, p->y, p->px, p->py, p->position, p->gun, p->author_id, p->isCanKillAuthor);
proto_send(type, client, msg);
}
@@ -611,8 +604,9 @@ void proto_recv_shot_client(char *msg)
return;
}
*/
- shot = newShot(x, y, px, py, gun, getTuxID(getCurrentArena()->listTux, author_id));
+ shot = newShot(x, y, px, py, gun, author_id);
+ shot->id = shot_id;
shot->isCanKillAuthor = isCanKillAuthor;
shot->position = position;