浏览代码

LoginServer support via database for max createable Chars per acct, and ceteran EXP bonus display requires SQL update.

Devn00b 1 年之前
父节点
当前提交
d2eb5f23d8

+ 36 - 0
EQ2/source/LoginServer/LoginDatabase.cpp

@@ -1001,3 +1001,39 @@ void LoginDatabase::UpdateAccountIPAddress(int32 account_id, int32 address){
 	Query query;
 	query.RunQuery2(Q_UPDATE, "update account set ip_address='%s' where id=%lu", inet_ntoa(in), account_id);
 }
+
+//devn00b: There is no rulesystem for login, so im going to use login_config for future things like this.
+//devn00b: Returns the number of characters a player may create per account. This should be set by server owners -> login,
+//devn00b: However, better semi-working for now than not working at all.
+//devn00b: TODO: EQ2World sends max char per acct.
+int8 LoginDatabase::GetMaxCharsSetting() {
+	//live defaults to 7 for GOLD members.
+	int8 max_chars = 7;
+	Query query;
+	MYSQL_ROW row;
+	
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "select config_value from login_config where config_name='max_characters_per_account'");
+	if (result && mysql_num_rows(result) == 1) {
+		row = mysql_fetch_row(result);
+		if (row[0])
+			max_chars = atoi(row[0]);
+	}
+	//if nothing else return the default.
+	return max_chars;
+}
+
+//TODO: EQ2World sends the servers max level for each server so we can do this correctly.
+int16 LoginDatabase::GetAccountBonus(int32 acct_id) {
+	int32 bonus = 0;
+	Query query;
+	MYSQL_ROW row;
+	
+	//pull all characters greater than the max level setting in the login_config table.
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT COUNT(id) FROM login_characters WHERE LEVEL >= (SELECT config_value FROM login_config WHERE config_name='max_level_for_vet_reward') AND account_id=%i", acct_id);
+	if (result && mysql_num_rows(result) == 1) {
+		row = mysql_fetch_row(result);
+		if(row[0])
+			bonus = atoi(row[0]);
+	}
+	return bonus;
+}

+ 2 - 0
EQ2/source/LoginServer/LoginDatabase.h

@@ -84,6 +84,8 @@ public:
 	void SetServerEquipmentAppearances(int32 server_id, map<int32, LoginEquipmentUpdate> equip_updates); // JohnAdams: login appearances
 	int32 GetLoginCharacterIDFromWorldCharID(int32 server_id, int32 char_id); // JohnAdams: login appearances
 	void RemoveDeletedCharacterData();
+	int8 GetMaxCharsSetting();
+	int16 GetAccountBonus(int32 acct_id);
 	DatabaseNew	dbLogin;
 };
 #endif

+ 5 - 3
EQ2/source/LoginServer/PacketHeaders.cpp

@@ -6,9 +6,11 @@
 */
 #include "PacketHeaders.h"
 #include "../common/MiscFunctions.h"
+#include "LoginDatabase.h"
 #include "LWorld.h"
 
 extern LWorldList	world_list;
+extern LoginDatabase database;
 
 void LS_DeleteCharacterRequest::loadData(EQApplicationPacket* packet){
 	InitializeLoadData(packet->pBuffer, packet->size);
@@ -27,7 +29,7 @@ EQ2Packet* LS_CharSelectList::serialize(int16 version){
 		account_info.account_id = account_id;
 		account_info.unknown1 = 0xFFFFFFFF;
 		account_info.unknown2 = 0;
-		account_info.maxchars = 10;
+		account_info.maxchars = 7; //live has a max of 7 on gold accounts base.	
 		account_info.unknown4 = 0;
 		AddData(account_info);
 	}
@@ -36,12 +38,12 @@ EQ2Packet* LS_CharSelectList::serialize(int16 version){
 		account_info.account_id = account_id;
 		account_info.unknown1 = 0xFFFFFFFF;
 		account_info.unknown2 = 0;
-		account_info.maxchars = 30; //devn00b:Corrected unknown and increased maxchars from 10 to 30.
+		account_info.maxchars = database.GetMaxCharsSetting(); 
 		account_info.unknown4 = 0;
 		for (int i = 0; i < 3; i++)
 			account_info.unknown5[i] = 0xFFFFFFFF;
 		account_info.unknown5[3] = 0;
-		account_info.vet_adv_bonus = 1;
+		account_info.vet_adv_bonus = database.GetAccountBonus(account_id);
 		account_info.vet_trade_bonus = 0;
 		AddData(account_info);
 	}