diff options
| author | Dusan Durech <dusan@debian.debian> | 2009-04-03 15:44:24 +0200 |
|---|---|---|
| committer | Dusan Durech <dusan@debian.debian> | 2009-04-03 15:44:24 +0200 |
| commit | ea026936031185a44ffe9e6a6ebe385aaed86e9d (patch) | |
| tree | 636c03110be963d86614bf5c921049041a7f9feb | |
| parent | 43a0c9e57cfdf03ce9e12dd64ce3825337dfb75b (diff) | |
-tux begin game with random gun, fix bug with offset lasser on client
| -rw-r--r-- | src/base/proto.c | 33 | ||||
| -rw-r--r-- | src/base/tux.c | 7 |
2 files changed, 35 insertions, 5 deletions
diff --git a/src/base/proto.c b/src/base/proto.c index f927dfa..69dd1a8 100644 --- a/src/base/proto.c +++ b/src/base/proto.c @@ -124,8 +124,13 @@ static void sendInfoCreateClient(client_t * client) thisClient = (client_t *) listClient->list[i]; thisTux = thisClient->tux; - if (thisTux != NULL && thisTux != client->tux) { + // odosli kazdemu stremu hracovy informacie o novom hracovy + if (thisTux != NULL && thisTux != client->tux) { proto_send_newtux_server(PROTO_SEND_ONE, thisClient, client->tux); + } + + // odosli novemu hracovy informacie o kazdom starom hracovy aj o sebe + if (thisTux != NULL) { proto_send_newtux_server(PROTO_SEND_ONE, client, thisTux); } } @@ -617,6 +622,25 @@ void proto_send_del_server(int type, client_t * client, int id) #ifndef PUBLIC_SERVER +void timer_delShot(void *p) +{ + shot_t *shot; + int *id; + + assert( p != NULL ); + id = (int *)(p); + + shot = getObjectFromSpaceWithID(getCurrentArena()->spaceShot, *id); + + if( shot != NULL ) + { + delFromRadar(shot->id); + delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); + } + + free(p); +} + void proto_recv_del_client(char *msg) { char cmd[STR_PROTO_SIZE]; @@ -648,8 +672,9 @@ void proto_recv_del_client(char *msg) if (shot != NULL) { //printf("delete shot..\n"); - delFromRadar(id); - delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); + //delFromRadar(id); + //delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); + addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_delShot, newInt(id), 50); return; } @@ -734,7 +759,7 @@ void proto_send_shot_server(int type, client_t * client, shot_t * p) assert(p != NULL); snprintf(msg, STR_PROTO_SIZE, "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, + p->id, p->x-p->px*8, p->y-p->py*8, p->px, p->py, p->position, p->gun, p->author_id, p->isCanKillAuthor); //proto_send(type, client, msg); diff --git a/src/base/tux.c b/src/base/tux.c index 5bb2305..a7e330f 100644 --- a/src/base/tux.c +++ b/src/base/tux.c @@ -68,6 +68,11 @@ void initTux() isTuxInit = TRUE; } +int getRandomGun() +{ + return random() % (GUN_BOMBBALL+1); +} + tux_t *newTux() { int x, y; @@ -86,7 +91,7 @@ tux_t *newTux() setTuxProportion(new, x, y); new->position = TUX_DOWN; - new->gun = GUN_SIMPLE; + new->gun = getRandomGun(); new->shot[new->gun] = GUN_MAX_SHOT; sprintf(new->name, "no_name_id_%d", new->id); |