summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2009-05-25 22:40:30 +0000
committerFate <fate-tmw@googlemail.com>2009-05-25 22:40:30 +0000
commitabb1b2ad079878b0750054982c95193200dd7bd5 (patch)
tree70ed99df5a07b0d478e5a0a038918371064a2a41 /src/char
parent208f15dd1bf61cb96df4e85b87e3d60eea55388e (diff)
downloadtmwa-abb1b2ad079878b0750054982c95193200dd7bd5.tar.gz
tmwa-abb1b2ad079878b0750054982c95193200dd7bd5.tar.bz2
tmwa-abb1b2ad079878b0750054982c95193200dd7bd5.tar.xz
tmwa-abb1b2ad079878b0750054982c95193200dd7bd5.zip
Made itemfrob an ladmin command that can be used while running the server
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.c46
-rw-r--r--src/char/int_storage.c9
-rw-r--r--src/char/int_storage.h1
3 files changed, 54 insertions, 2 deletions
diff --git a/src/char/char.c b/src/char/char.c
index b8ce145..b14f25c 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1778,6 +1778,50 @@ int parse_tologin(int fd) {
}
break;
+ case 0x7924: { // [Fate] Itemfrob package: forwarded from login-server
+ if (RFIFOREST(fd) < 10)
+ return 0;
+ int source_id = RFIFOL(fd, 2);
+ int dest_id = RFIFOL(fd, 6);
+ unsigned char buf[10];
+
+ WBUFW(buf, 0) = 0x2afa;
+ WBUFL(buf, 2) = source_id;
+ WBUFL(buf, 6) = dest_id;
+
+ mapif_sendall(buf, 10); // forward package to map servers
+ for (i = 0; i < char_num; i++) {
+ struct mmo_charstatus *c = char_dat + i;
+ struct storage *s = account2maybe_storage(c->account_id);
+ int changes = 0;
+ int j;
+#define FIX(v) if (v == source_id) {v = dest_id; ++changes; }
+ for (j = 0; j < MAX_INVENTORY; j++)
+ FIX(c->inventory[j].nameid);
+ for (j = 0; j < MAX_CART; j++)
+ FIX(c->cart[j].nameid);
+ FIX(c->weapon);
+ FIX(c->shield);
+ FIX(c->head_top);
+ FIX(c->head_mid);
+ FIX(c->head_bottom);
+
+ if (s)
+ for (j = 0; j < s->storage_amount; j++)
+ FIX(s->storage[j].nameid);
+#undef FIX
+ if (changes)
+ char_log("itemfrob(%d -> %d): `%s'(%d, account %d): changed %d times\n", source_id, dest_id,
+ c->name, c->char_id, c->account_id, changes);
+
+ }
+
+ mmo_char_sync();
+ inter_storage_save();
+ RFIFOSKIP(fd,10);
+ break;
+ }
+
// Account deletion notification (from login-server)
case 0x2730:
if (RFIFOREST(fd) < 6)
@@ -2954,7 +2998,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data) {
//----------------------------------------------------------
// Return numerical value of a switch configuration by [Yor]
-// on/off, english, franais, deutsch, espaol
+// on/off, english, franais, deutsch, espanol
//----------------------------------------------------------
int config_switch(const char *str) {
if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0)
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index b84b586..0774370 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -190,10 +190,17 @@ int guild_storage_fromstr(char *str,struct guild_storage *p)
}
// AJEgqɃf[^CfbNX𓾂iVKqɒlj”\j
-struct storage *account2storage(int account_id)
+struct storage *account2maybe_storage(int account_id)
{
struct storage *s;
s=numdb_search(storage_db,account_id);
+ return s;
+}
+
+struct storage *account2storage(int account_id)
+{
+ struct storage *s = account2maybe_storage(account_id);
+
if(s == NULL) {
s = calloc(sizeof(struct storage), 1);
if(s==NULL){
diff --git a/src/char/int_storage.h b/src/char/int_storage.h
index d918f5f..59f56c6 100644
--- a/src/char/int_storage.h
+++ b/src/char/int_storage.h
@@ -7,6 +7,7 @@ int inter_storage_save();
int inter_guild_storage_save();
int inter_storage_delete(int account_id);
int inter_guild_storage_delete(int guild_id);
+struct storage *account2maybe_storage(int account_id);
int inter_storage_parse_frommap(int fd);