[sylverant] r768 committed - ship_server changes to go along with that last shipgate changeset.

1 view
Skip to first unread message

sylv...@googlecode.com

unread,
Dec 29, 2014, 4:23:55 PM12/29/14
to sylverant-...@googlegroups.com
Revision: 768
Author: bluecrab
Date: Mon Dec 29 21:23:30 2014 UTC
Log: ship_server changes to go along with that last shipgate changeset.


https://code.google.com/p/sylverant/source/detail?r=768

Modified:
/trunk/ship_server/src/clients.h
/trunk/ship_server/src/commands.c
/trunk/ship_server/src/lobby.c
/trunk/ship_server/src/lobby.h
/trunk/ship_server/src/shipgate.c
/trunk/ship_server/src/shipgate.h

=======================================
--- /trunk/ship_server/src/clients.h Mon Jul 29 19:54:10 2013 UTC
+++ /trunk/ship_server/src/clients.h Mon Dec 29 21:23:30 2014 UTC
@@ -1,6 +1,6 @@
/*
Sylverant Ship Server
- Copyright (C) 2009, 2010, 2011, 2012, 2013 Lawrence Sebald
+ Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Lawrence Sebald

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
@@ -247,6 +247,7 @@
#define CLIENT_FLAG_GC_PROTECT 0x00008000
#define CLIENT_FLAG_IS_DCNTE 0x00010000
#define CLIENT_FLAG_TRACK_INVENTORY 0x00020000
+#define CLIENT_FLAG_TRACK_KILLS 0x00040000

/* The list of language codes for the quest directories. */
static const char language_codes[][3] __attribute__((unused)) = {
=======================================
--- /trunk/ship_server/src/commands.c Wed Oct 16 00:38:09 2013 UTC
+++ /trunk/ship_server/src/commands.c Mon Dec 29 21:23:30 2014 UTC
@@ -1,6 +1,6 @@
/*
Sylverant Ship Server
- Copyright (C) 2009, 2010, 2011, 2012, 2013 Lawrence Sebald
+ Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Lawrence Sebald

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
@@ -218,7 +218,7 @@
return send_txt(c, "%s",
__(c, "\tE\tC7Maximum level must be >= minimum."));
}
-
+
/* Set the value in the structure, and be on our way. */
l->max_level = lvl;

@@ -996,7 +996,7 @@

/* Send a request to the shipgate to do the rest */
shipgate_send_friend_add(&ship->sg, c->guildcard, gc, nick + 1);
-
+
/* Any further messages will be handled by the shipgate handler */
return 0;
}
@@ -1427,7 +1427,7 @@
c->guildcard);

for(i = 0; i < c->item_count; ++i) {
- debug(DBG_LOG, "%d (%08x): %08x %08x %08x %08x: %s\n", i,
+ debug(DBG_LOG, "%d (%08x): %08x %08x %08x %08x: %s\n", i,
LE32(c->items[i].item_id), LE32(c->items[i].data_l[0]),
LE32(c->items[i].data_l[1]),
LE32(c->items[i].data_l[2]),
LE32(c->items[i].data2_l), item_get_name(&c->items[i]));
@@ -1438,7 +1438,7 @@
debug(DBG_LOG, "Inventory dump for %s (%d)\n", name, c->guildcard);

for(i = 0; i < c->bb_pl->inv.item_count; ++i) {
- debug(DBG_LOG, "%d (%08x): %08x %08x %08x %08x: %s\n", i,
+ debug(DBG_LOG, "%d (%08x): %08x %08x %08x %08x: %s\n", i,
LE32(c->bb_pl->inv.items[i].item_id),
LE32(c->bb_pl->inv.items[i].data_l[0]),
LE32(c->bb_pl->inv.items[i].data_l[1]),
@@ -1463,7 +1463,7 @@
l->lobby_id);

TAILQ_FOREACH(j, &l->item_queue, qentry) {
- debug(DBG_LOG, "%08x: %08x %08x %08x %08x: %s\n",
+ debug(DBG_LOG, "%08x: %08x %08x %08x %08x: %s\n",
LE32(j->d.item_id), LE32(j->d.data_l[0]),
LE32(j->d.data_l[1]), LE32(j->d.data_l[2]),
LE32(j->d.data2_l), item_get_name(&j->d));
@@ -1629,7 +1629,7 @@
else {
snprintf(str, 511, "%s%d: None ", str, i);
}
-
+
if((i + 1) < l->max_clients) {
if((c2 = l->clients[i + 1])) {
snprintf(str, 511, "%s%d: %s\n", str, i + 1,
@@ -2688,26 +2688,6 @@
return send_txt(c, "%s", __(c, "\tE\tC7Guildcard protection
enabled."));
}

-/* Usage: /mk */
-static int handle_mk(ship_client_t *c, const char *params) {
- lobby_t *l = c->cur_lobby;
-
- /* Make sure the requester is a local GM, at least. */
- if(!LOCAL_GM(c)) {
- return send_txt(c, "%s", __(c, "\tE\tC7Nice try."));
- }
-
- /* Make sure that the requester is in a game lobby, not a lobby lobby
*/
- if(l->type != LOBBY_TYPE_GAME) {
- return send_txt(c, "%s", __(c, "\tE\tC7Only valid in a game."));
- }
-
- /* Set the flag... */
- l->flags |= LOBBY_FLAG_MK;
-
- return send_txt(c, "%s", __(c, "\tE\tC7Flag set."));
-}
-
/* Usage: /trackinv */
static int handle_trackinv(ship_client_t *c, const char *params) {
lobby_t *l = c->cur_lobby;
@@ -2725,6 +2705,32 @@

return send_txt(c, "%s", __(c, "\tE\tC7Flag set."));
}
+
+/* Usage /trackkill [off] */
+static int handle_trackkill(ship_client_t *c, const char *params) {
+ uint8_t enable = 1;
+
+ /* Make sure they're logged in */
+ if(!(c->flags & CLIENT_FLAG_LOGGED_IN)) {
+ return send_txt(c, "%s", __(c, "\tE\tC7You must be logged in to "
+ "use this command."));
+ }
+
+ /* See if we're turning the flag off. */
+ if(!strcmp(params, "off")) {
+ enable = 0;
+ shipgate_send_user_opt(&ship->sg, c->guildcard, c->cur_block->b,
+ USER_OPT_TRACK_KILLS, 1, &enable);
+ c->flags &= ~CLIENT_FLAG_TRACK_KILLS;
+ return send_txt(c, "%s", __(c, "\tE\tC7Kill tracking disabled."));
+ }
+
+ /* Send the message to the shipgate */
+ shipgate_send_user_opt(&ship->sg, c->guildcard, c->cur_block->b,
+ USER_OPT_TRACK_KILLS, 1, &enable);
+ c->flags |= CLIENT_FLAG_TRACK_KILLS;
+ return send_txt(c, "%s", __(c, "\tE\tC7Kill tracking enabled."));
+}

static command_t cmds[] = {
{ "warp" , handle_warp },
@@ -2803,8 +2809,8 @@
{ "level" , handle_level },
{ "sdrops" , handle_sdrops },
{ "gcprotect", handle_gcprotect },
- { "mk" , handle_mk },
{ "trackinv" , handle_trackinv },
+ { "trackkill", handle_trackkill },
{ "" , NULL } /* End marker -- DO NOT DELETE */
};

=======================================
--- /trunk/ship_server/src/lobby.c Sat Jul 27 00:27:46 2013 UTC
+++ /trunk/ship_server/src/lobby.c Mon Dec 29 21:23:30 2014 UTC
@@ -1,6 +1,6 @@
/*
Sylverant Ship Server
- Copyright (C) 2009, 2010, 2011, 2012, 2013 Lawrence Sebald
+ Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Lawrence Sebald

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
@@ -51,7 +51,7 @@

/* Clear it, and set up the specified parameters. */
memset(l, 0, sizeof(lobby_t));
-
+
l->lobby_id = lobby_id;
l->type = LOBBY_TYPE_DEFAULT;
l->max_clients = LOBBY_MAX_CLIENTS;
@@ -433,7 +433,7 @@
break;
}
}
-
+
break;

case CLIENT_VERSION_PC:
@@ -442,7 +442,7 @@
break;
}
}
-
+
break;

case CLIENT_VERSION_GC:
@@ -983,10 +983,8 @@

/* If the client is leaving a game lobby, then send their monster stats
up to the shipgate. */
- if(l->type == LOBBY_TYPE_GAME && (l->flags & LOBBY_FLAG_MK)) {
- shipgate_send_mkill(&ship->sg, c->guildcard, c->cur_block->b,
- l->episode, l->difficulty, c->enemy_kills);
- }
+ if(l->type == LOBBY_TYPE_GAME && (c->flags & CLIENT_FLAG_TRACK_KILLS))
+ shipgate_send_mkill(&ship->sg, c->guildcard, c->cur_block->b, c,
l);

/* We have a nice function to handle most of the heavy lifting... */
client_id = c->client_id;
@@ -1274,7 +1272,7 @@

if(!irv) {
debug(DBG_LOG, "Potentially non-legit item in legit mode:\n"
- "%08x %08x %08x %08x\n", LE32(item->data_l[0]),
+ "%08x %08x %08x %08x\n", LE32(item->data_l[0]),
LE32(item->data_l[1]), LE32(item->data_l[2]),
LE32(item->data2_l));
rv = irv;
=======================================
--- /trunk/ship_server/src/lobby.h Sun Jul 20 20:42:59 2014 UTC
+++ /trunk/ship_server/src/lobby.h Mon Dec 29 21:23:30 2014 UTC
@@ -158,7 +158,7 @@
#define LOBBY_FLAG_SINGLEPLAYER 0x00000400
#define LOBBY_FLAG_EP3 0x00000800
#define LOBBY_FLAG_SERVER_DROPS 0x00001000
-#define LOBBY_FLAG_MK 0x00002000
+/* 0x00002000 currently unused. */
#define LOBBY_FLAG_DCNTE 0x00004000

/* Events that can be set on games */
=======================================
--- /trunk/ship_server/src/shipgate.c Sun Nov 18 05:43:40 2012 UTC
+++ /trunk/ship_server/src/shipgate.c Mon Dec 29 21:23:30 2014 UTC
@@ -1,6 +1,6 @@
/*
Sylverant Ship Server
- Copyright (C) 2009, 2010, 2011, 2012 Lawrence Sebald
+ Copyright (C) 2009, 2010, 2011, 2012, 2014 Lawrence Sebald

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
@@ -738,7 +738,7 @@
TAILQ_FOREACH(i, &s->ships, qentry) {
/* Clear the ship from the list, if we've found the right one
*/
if(sid == i->ship_id) {
- TAILQ_REMOVE(&s->ships, i, qentry);
+ TAILQ_REMOVE(&s->ships, i, qentry);
ship_found = 1;
break;
}
@@ -1658,6 +1658,18 @@
i->join_time = time(NULL);
}
break;
+
+ case USER_OPT_TRACK_KILLS:
+ /* Make sure the length is right */
+ if(length != 16)
+ break;
+
+ /* The only byte of the data that's used is the
first
+ one. It is a boolean saying whether or not to
enable
+ kill tracking. */
+ if(opt->data[0])
+ i->flags |= CLIENT_FLAG_TRACK_KILLS;
+ break;
}

/* Adjust the pointers to the next option */
@@ -1759,7 +1771,7 @@

case SHDR_TYPE_ADDFRIEND:
return handle_addfriend(conn, (shipgate_friend_err_pkt
*)pkt);
-
+
case SHDR_TYPE_DELFRIEND:
return handle_delfriend(conn, (shipgate_friend_err_pkt
*)pkt);

@@ -1996,7 +2008,7 @@
pkt->guildcard = htonl(gc);
pkt->slot = htonl(slot);
pkt->block = htonl(block);
- memcpy(pkt->data, cdata, len);
+ memcpy(pkt->data, cdata, len);

/* Send it away. */
return send_crypt(c, sizeof(shipgate_char_data_pkt) + len, sendbuf);
@@ -2255,7 +2267,7 @@
pkt->req_gc = htonl(requester);
pkt->target = htonl(target);
pkt->until = htonl(until);
- strncpy(pkt->message, msg, 255);
+ strncpy(pkt->message, msg, 255);

/* Send the packet away */
return send_crypt(c, sizeof(shipgate_ban_req_pkt), sendbuf);
@@ -2687,7 +2699,7 @@
pkt->block = htonl(block);
strncpy((char *)pkt->name, name, 32);
pkt->name[31] = 0;
- memcpy(pkt->data, cdata, len);
+ memcpy(pkt->data, cdata, len);

/* Send it away. */
return send_crypt(c, sizeof(shipgate_char_bkup_pkt) + len, sendbuf);
@@ -2720,29 +2732,38 @@

/* Send a monster kill count update */
int shipgate_send_mkill(shipgate_conn_t *c, uint32_t gc, uint32_t block,
- uint8_t ep, uint8_t d, uint32_t counts[0x60]) {
+ ship_client_t *cl, lobby_t *l) {
uint8_t *sendbuf = get_sendbuf();
shipgate_mkill_pkt *pkt = (shipgate_mkill_pkt *)sendbuf;
int i;

/* Verify we got the sendbuf. */
- if(!sendbuf) {
+ if(!sendbuf)
return -1;
- }

/* Fill in the header and the body. */
pkt->hdr.pkt_len = htons(sizeof(shipgate_mkill_pkt));
pkt->hdr.pkt_type = htons(SHDR_TYPE_MKILL);
- pkt->hdr.version = pkt->hdr.reserved = 0;
+ pkt->hdr.version = 1;
+ pkt->hdr.reserved = 0;
pkt->hdr.flags = 0;
pkt->guildcard = htonl(gc);
pkt->block = htonl(block);
- pkt->episode = ep ? ep : 1;
- pkt->difficulty = d;
- pkt->reserved[0] = pkt->reserved[1] = 0;
+ pkt->episode = l->episode ? l->episode : 1;
+ pkt->difficulty = l->difficulty;
+ pkt->version = (uint8_t)cl->version;
+ pkt->reserved = 0;
+
+ if(l->battle)
+ pkt->version |= CLIENT_BATTLE_MODE;
+ else if(l->challenge)
+ pkt->version |= CLIENT_CHALLENGE_MODE;
+
+ if(l->qid)
+ pkt->version |= CLIENT_QUESTING;

for(i = 0; i < 0x60; ++i) {
- pkt->counts[i] = ntohl(counts[i]);
+ pkt->counts[i] = ntohl(cl->enemy_kills[i]);
}

/* Send it away. */
=======================================
--- /trunk/ship_server/src/shipgate.h Fri Jul 5 00:38:16 2013 UTC
+++ /trunk/ship_server/src/shipgate.h Mon Dec 29 21:23:30 2014 UTC
@@ -1,6 +1,6 @@
/*
Sylverant Ship Server
- Copyright (C) 2009, 2010, 2011, 2012, 2013 Lawrence Sebald
+ Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Lawrence Sebald

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
@@ -33,12 +33,24 @@

/* Forward declarations. */
struct ship;
+struct ship_client;
+struct lobby;

#ifndef SHIP_DEFINED
#define SHIP_DEFINED
typedef struct ship ship_t;
#endif

+#ifndef SHIP_CLIENT_DEFINED
+#define SHIP_CLIENT_DEFINED
+typedef struct ship_client ship_client_t;
+#endif
+
+#ifndef LOBBY_DEFINED
+#define LOBBY_DEFINED
+typedef struct lobby lobby_t;
+#endif
+
#ifdef PACKED
#undef PACKED
#endif
@@ -398,17 +410,19 @@
sylverant_bb_db_opts_t opts;
} PACKED shipgate_bb_opts_pkt;

-/* Packet used to send an update to the user's monster kill counts. */
+/* Packet used to send an update to the user's monster kill counts.
+ Version 1 adds a client version code where there used to be a reserved
byte
+ in the packet. */
typedef struct shipgate_mkill {
shipgate_hdr_t hdr;
uint32_t guildcard;
uint32_t block;
uint8_t episode;
uint8_t difficulty;
- uint8_t reserved[2];
+ uint8_t version;
+ uint8_t reserved;
uint32_t counts[0x60];
} PACKED shipgate_mkill_pkt;
-
#undef PACKED

/* Size of the shipgate login packet. */
@@ -498,11 +512,17 @@
#define USER_OPT_QUEST_LANG 0x00000001
#define USER_OPT_ENABLE_BACKUP 0x00000002
#define USER_OPT_GC_PROTECT 0x00000003
+#define USER_OPT_TRACK_KILLS 0x00000004

/* Possible values for the fw_flags on a forwarded packet */
#define FW_FLAG_PREFER_IPV6 0x00000001 /* Prefer IPv6 on reply */
#define FW_FLAG_IS_PSOPC 0x00000002 /* Client is on PSOPC */

+/* Potentially ORed with any version codes, if needed/appropriate. */
+#define CLIENT_QUESTING 0x20
+#define CLIENT_CHALLENGE_MODE 0x40
+#define CLIENT_BATTLE_MODE 0x80
+
/* Attempt to connect to the shipgate. Returns < 0 on error, returns 0 on
success. */
int shipgate_connect(ship_t *s, shipgate_conn_t *rv);
@@ -606,6 +626,6 @@

/* Send a monster kill count update */
int shipgate_send_mkill(shipgate_conn_t *c, uint32_t gc, uint32_t block,
- uint8_t ep, uint8_t d, uint32_t counts[0x60]);
+ ship_client_t *cl, lobby_t *l);

#endif /* !SHIPGATE_H */
Reply all
Reply to author
Forward
0 new messages