// 倉庫データを文字列に変換 static FString storage_tostr(struct storage *p) { MString str; str += STRPRINTF( "%d,%d\t", p->account_id, p->storage_amount); int f = 0; for (int i = 0; i < MAX_STORAGE; i++) if (p->storage_[i].nameid && p->storage_[i].amount) { str += STRPRINTF( "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", p->storage_[i].id, p->storage_[i].nameid, p->storage_[i].amount, p->storage_[i].equip, p->storage_[i].identify, p->storage_[i].refine, p->storage_[i].attribute, p->storage_[i].card[0], p->storage_[i].card[1], p->storage_[i].card[2], p->storage_[i].card[3]); f++; } str += '\t'; if (!f) return FString(); return FString(str); }
// パーティデータの文字列への変換 static FString inter_party_tostr(struct party *p) { MString str; str += STRPRINTF( "%d\t" "%s\t" "%d,%d\t", p->party_id, p->name, p->exp, p->item); for (int i = 0; i < MAX_PARTY; i++) { struct party_member *m = &p->member[i]; if (!m->account_id) continue; str += STRPRINTF( "%d,%d\t" "%s\t", m->account_id, m->leader, m->name); } return FString(str); }
void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length) { if (length == 0 || sd->auto_ban_info.in_progress) return; sd->auto_ban_info.in_progress = 1; AString hack_msg = STRPRINTF("[GM] %s has been autobanned for %s spam"_fmt, sd->status_key.name, reason); tmw_GmHackMsg(hack_msg); AString fake_command = STRPRINTF("@autoban %s %dh (%s spam)"_fmt, sd->status_key.name, length, reason); log_atcommand(sd, fake_command); AString anotherbuf = STRPRINTF("You have been banned for %s spamming. Please do not spam."_fmt, reason); clif_displaymessage(sd->sess, anotherbuf); /* type: 2 - ban(year, month, day, hour, minute, second) */ HumanTimeDiff ban_len {}; ban_len.hour = length; chrif_char_ask_name(AccountId(), sd->status_key.name, 2, ban_len); clif_setwaitclose(sd->sess); }
char* kogmo_rtdb_obj_dumpbase_str (kogmo_rtdb_handle_t *db_h, void *data_p) { kogmo_rtdb_subobj_base_t *objbase; kogmo_timestamp_string_t tstr, data_tstr; kogmo_rtdb_obj_c3_process_info_t pi; NEWSTR(buf); objbase = (kogmo_rtdb_subobj_base_t*) data_p; if ( objbase->size < (int)(sizeof(kogmo_rtdb_subobj_base_t)) ) { STRPRINTF(buf,"* NO DATA\n"); return buf; } kogmo_timestamp_to_string(objbase->committed_ts, tstr); kogmo_timestamp_to_string(objbase->data_ts, data_tstr); kogmo_rtdb_obj_c3_process_getprocessinfo (db_h, objbase->committed_proc, objbase->committed_ts, pi); STRPRINTF(buf,"* DATA:\n"); STRPRINTF(buf,"Committed: %s by %s, %lli bytes\n", tstr, pi, (long long int)objbase->size); STRPRINTF(buf,"Data created: %s\n", data_tstr); return buf; }
// アカウント変数を文字列へ変換 static FString inter_accreg_tostr(struct accreg *reg) { MString str; str += STRPRINTF("%d\t", reg->account_id); for (int j = 0; j < reg->reg_num; j++) str += STRPRINTF("%s,%d ", reg->reg[j].str, reg->reg[j].value); return FString(str); }
char* kogmo_rtdb_obj_dumphex_str (kogmo_rtdb_handle_t *db_h, void *data_p) { kogmo_rtdb_objsize_t size; int i; NEWSTR(buf); size = ( (kogmo_rtdb_subobj_base_t*) data_p )->size; STRPRINTF(buf, "* BINARY DATA:\n"); for(i=0;i<size;i++) { STRPRINTF(buf,"%02x ", ((unsigned char*)data_p)[i]); } STRPRINTF(buf,"\n"); return buf; }
static void intif_parse_PartyLeaderChanged(Session *, const Packet_Fixed<0x3828>& fixed) { int i; PartyPair p = TRY_UNWRAP(party_search(fixed.party_id), return); for (i = 0; i < MAX_PARTY; i++) { PartyMember *m = &p->member[i]; if (m->account_id == fixed.account_id) { dumb_ptr<map_session_data> sd = map_id2sd(wrap<BlockId>(unwrap<AccountId>(fixed.account_id))); m->leader = (fixed.leader > 0 ? 1 : 0); if (sd != nullptr) { AString msg = STRPRINTF("You are %s a leader of %s."_fmt, fixed.leader > 0 ? "now"_s : "no longer"_s, p->name); clif_displaymessage(sd->sess, msg); } break; } } clif_party_info(p, nullptr); }
char* FormatTimeHourMinOnly(char* outBuffer, size_t len, unsigned int inSeconds) { int seconds = (inSeconds % 60); int minutes = ((inSeconds - seconds) / 60) % 60; int hours = (inSeconds - (minutes * 60) - (seconds)) / (60 * 60); STRPRINTF(outBuffer, len, "%02d:%02d", hours, minutes); return outBuffer; }
char* FormatTimeWords(char* outBuffer, size_t len, unsigned int inSeconds, bool abbreviate, const char ** pLocalizedTimeUnits) { if(pLocalizedTimeUnits == NULL) pLocalizedTimeUnits = s_DefaultTimeUintStr; if(inSeconds >= (24*60*60)) { int days = inSeconds / (24*60*60); if(days == 1) { STRPRINTF(outBuffer, len, "1 %s", pLocalizedTimeUnits[TU_DAY]); } else { STRPRINTF(outBuffer, len, "%d %s", days, pLocalizedTimeUnits[TU_DAYS]); } } else if(inSeconds >= (60*60)) { int hours = inSeconds / (60*60); if(hours == 1) { const char* strTU = (abbreviate)?pLocalizedTimeUnits[TU_ABBR_HOUR]:pLocalizedTimeUnits[TU_HOUR]; STRPRINTF(outBuffer, len, "1 %s", strTU); } else { const char* strTU = (abbreviate)?pLocalizedTimeUnits[TU_ABBR_HOURS]:pLocalizedTimeUnits[TU_HOURS]; STRPRINTF(outBuffer, len, "%d %s", hours, strTU); } } else if(inSeconds >= 60) { int minutes = inSeconds / (60); if(minutes == 1) { const char* strTU = (abbreviate)?pLocalizedTimeUnits[TU_ABBR_MINUTE]:pLocalizedTimeUnits[TU_MINUTE]; STRPRINTF(outBuffer, len, "1 %s", strTU); } else { const char* strTU = (abbreviate)?pLocalizedTimeUnits[TU_ABBR_MINUTE]:pLocalizedTimeUnits[TU_MINUTES]; STRPRINTF(outBuffer, len, "%d %s", minutes, strTU); } } else { if(inSeconds == 1) { const char* strTU = (abbreviate)?pLocalizedTimeUnits[TU_ABBR_SECOND]:pLocalizedTimeUnits[TU_SECOND]; STRPRINTF(outBuffer, len, "1 %s", strTU); } else { const char* strTU = (abbreviate)?pLocalizedTimeUnits[TU_ABBR_SECOND]:pLocalizedTimeUnits[TU_SECONDS]; STRPRINTF(outBuffer, len, "%d %s", inSeconds, strTU); } } //STRPRINTF(outBuffer, len, "%02d:%02d:%02d", hours, minutes, seconds); return outBuffer; }
/*========================================== * Disconnection of a player (account has been banned of has a status, from login-server) by [Yor] *------------------------------------------ */ static int chrif_accountban(Session *, const Packet_Fixed<0x2b14>& fixed) { dumb_ptr<map_session_data> sd; AccountId acc = fixed.account_id; if (battle_config.etc_log) PRINTF("chrif_accountban %d.\n"_fmt, acc); sd = map_id2sd(account_to_block(acc)); if (acc) { if (sd != nullptr) { sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters if (fixed.ban_not_status == 0) { // 0: change of statut, 1: ban switch (static_cast<time_t>(fixed.status_or_ban_until)) { // status or final date of a banishment case 1: // 0 = Unregistered ID clif_displaymessage(sd->sess, "Your account has 'Unregistered'."_s); break; case 2: // 1 = Incorrect Password clif_displaymessage(sd->sess, "Your account has an 'Incorrect Password'..."_s); break; case 3: // 2 = This ID is expired clif_displaymessage(sd->sess, "Your account has expired."_s); break; case 4: // 3 = Rejected from Server clif_displaymessage(sd->sess, "Your account has been rejected from server."_s); break; case 5: // 4 = You have been blocked by the GM Team clif_displaymessage(sd->sess, "Your account has been blocked by the GM Team."_s); break; case 6: // 5 = Your Game's EXE file is not the latest version clif_displaymessage(sd->sess, "Your Game's EXE file is not the latest version."_s); break; case 7: // 6 = Your are Prohibited to log in until %s clif_displaymessage(sd->sess, "Your account has been prohibited to log in."_s); break; case 8: // 7 = Server is jammed due to over populated clif_displaymessage(sd->sess, "Server is jammed due to over populated."_s); break; case 9: // 8 = No MSG (actually, all states after 9 except 99 are No MSG, use only this) clif_displaymessage(sd->sess, "Your account has not more authorised."_s); break; case 100: // 99 = This ID has been totally erased clif_displaymessage(sd->sess, "Your account has been totally erased."_s); break; default: clif_displaymessage(sd->sess, "Your account has not more authorised."_s); break; } } else if (fixed.ban_not_status == 1) { // 0: change of statut, 1: ban const TimeT timestamp = fixed.status_or_ban_until; // status or final date of a banishment timestamp_seconds_buffer buffer; stamp_time(buffer, ×tamp); AString tmpstr = STRPRINTF("Your account has been banished until %s"_fmt, buffer); clif_displaymessage(sd->sess, tmpstr); } clif_setwaitclose(sd->sess); // forced to disconnect for the change } } else { if (sd != nullptr) PRINTF("chrif_accountban failed - player not online.\n"_fmt); } return 0; }
/*========================================== * Answer after a request about a character name to do some operations (by Yor) * Used to answer of chrif_char_ask_name. * type of operation: * 1: block * 2: ban * 3: unblock * 4: unban * 5: changesex * type of answer: * 0: login-server resquest done * 1: player not found * 2: gm level too low * 3: login-server offline *------------------------------------------ */ static int chrif_char_ask_name_answer(Session *, const Packet_Fixed<0x2b0f>& fixed) { AccountId acc = fixed.account_id; // who asked, or nobody CharName player_name = fixed.char_name; dumb_ptr<map_session_data> sd = map_id2sd(account_to_block(acc)); if (acc && sd != nullptr) { AString output; if (fixed.error == 1) // player not found output = STRPRINTF("The player '%s' doesn't exist."_fmt, player_name); else { switch (fixed.operation) { case 1: // block switch (fixed.error) { case 0: // login-server resquest done output = STRPRINTF( "Login-server has been asked to block the player '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( "Your GM level don't authorise you to block the player '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( "Login-server is offline. Impossible to block the the player '%s'."_fmt, player_name); break; } break; case 2: // ban switch (fixed.error) { case 0: // login-server resquest done output = STRPRINTF( "Login-server has been asked to ban the player '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( "Your GM level don't authorise you to ban the player '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( "Login-server is offline. Impossible to ban the the player '%s'."_fmt, player_name); break; } break; case 3: // unblock switch (fixed.error) { case 0: // login-server resquest done output = STRPRINTF( "Login-server has been asked to unblock the player '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( "Your GM level don't authorise you to unblock the player '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( "Login-server is offline. Impossible to unblock the the player '%s'."_fmt, player_name); break; } break; case 4: // unban switch (fixed.error) { case 0: // login-server resquest done output = STRPRINTF( "Login-server has been asked to unban the player '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( "Your GM level don't authorise you to unban the player '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( "Login-server is offline. Impossible to unban the the player '%s'."_fmt, player_name); break; } break; case 5: // changesex switch (fixed.error) { case 0: // login-server resquest done output = STRPRINTF( "Login-server has been asked to change the sex of the player '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( "Your GM level don't authorise you to change the sex of the player '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( "Login-server is offline. Impossible to change the sex of the the player '%s'."_fmt, player_name); break; } break; } } if (output) clif_displaymessage(sd->sess, output); } else PRINTF("chrif_char_ask_name_answer failed - player not online.\n"_fmt); return 0; }
static void stringify(val_t *v, int within_op) { static earray<ZString, DIR, DIR::COUNT> dirs //= {{ {"south"}, {"south-west"}, {"west"}, {"north-west"}, {"north"}, {"north-east"}, {"east"}, {"south-east"}, }}; FString buf; switch (v->ty) { case TYPE::UNDEF: buf = "UNDEF"; break; case TYPE::INT: buf = STRPRINTF("%i", v->v.v_int); break; case TYPE::STRING: return; case TYPE::DIR: buf = dirs[v->v.v_dir]; break; case TYPE::ENTITY: buf = show_entity(v->v.v_entity); break; case TYPE::LOCATION: buf = STRPRINTF("<\"%s\", %d, %d>", v->v.v_location.m->name_, v->v.v_location.x, v->v.v_location.y); break; case TYPE::AREA: buf = "%area"; free_area(v->v.v_area); break; case TYPE::SPELL: buf = v->v.v_spell->name; break; case TYPE::INVOCATION: { dumb_ptr<invocation> invocation_ = within_op ? v->v.v_invocation : map_id2bl(v->v.v_int)->as_spell(); buf = invocation_->spell->name; } break; default: FPRINTF(stderr, "[magic] INTERNAL ERROR: Cannot stringify %d\n", v->ty); return; } v->v.v_string = dumb_string::copys(buf); v->ty = TYPE::STRING; }