Bläddra i källkod

Move EXP per level to database.

devn00b 6 månader sedan
förälder
incheckning
2f9aaef8d5

+ 125 - 0
DB/updates/exp_per_level_apr21-24.sql

@@ -0,0 +1,125 @@
+-- --------------------------------------------------------
+-- Host:                         127.0.0.1
+-- Server version:               10.11.6-MariaDB-0+deb12u1 - Debian 12
+-- Server OS:                    debian-linux-gnu
+-- HeidiSQL Version:             12.6.0.6765
+-- --------------------------------------------------------
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET NAMES utf8 */;
+/*!50503 SET NAMES utf8mb4 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+-- Dumping structure for table eq2emu.exp_per_level
+CREATE TABLE IF NOT EXISTS `exp_per_level` (
+  `level` int(10) unsigned NOT NULL,
+  `exp_needed` int(10) unsigned DEFAULT NULL,
+  PRIMARY KEY (`level`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
+
+-- Dumping data for table eq2emu.exp_per_level: ~94 rows (approximately)
+INSERT INTO `exp_per_level` (`level`, `exp_needed`) VALUES
+	(2, 600),
+	(3, 800),
+	(4, 1000),
+	(5, 1400),
+	(6, 1800),
+	(7, 2200),
+	(8, 2600),
+	(9, 3000),
+	(10, 3400),
+	(11, 3800),
+	(12, 4200),
+	(13, 4600),
+	(14, 5000),
+	(15, 5500),
+	(16, 6000),
+	(17, 6500),
+	(18, 7000),
+	(19, 7500),
+	(20, 8000),
+	(21, 8500),
+	(22, 9000),
+	(23, 9500),
+	(24, 10000),
+	(25, 10500),
+	(26, 11000),
+	(27, 11750),
+	(28, 12500),
+	(29, 13250),
+	(30, 14000),
+	(31, 14750),
+	(32, 15500),
+	(33, 16250),
+	(34, 17000),
+	(35, 17750),
+	(36, 18500),
+	(37, 19250),
+	(38, 20000),
+	(39, 20750),
+	(40, 21500),
+	(41, 22250),
+	(42, 23000),
+	(43, 24000),
+	(44, 25000),
+	(45, 26000),
+	(46, 27000),
+	(47, 28000),
+	(48, 29250),
+	(49, 30500),
+	(50, 32000),
+	(51, 33750),
+	(52, 35750),
+	(53, 38000),
+	(54, 40500),
+	(55, 42500),
+	(56, 45500),
+	(57, 48500),
+	(58, 51500),
+	(59, 54500),
+	(60, 57500),
+	(61, 60500),
+	(62, 63500),
+	(63, 66500),
+	(64, 70000),
+	(65, 73500),
+	(66, 77000),
+	(67, 80500),
+	(68, 84000),
+	(69, 87500),
+	(70, 91000),
+	(71, 94500),
+	(72, 98000),
+	(73, 101500),
+	(74, 105000),
+	(75, 108500),
+	(76, 116500),
+	(77, 132500),
+	(78, 152500),
+	(79, 172500),
+	(80, 192500),
+	(81, 212500),
+	(82, 232500),
+	(83, 252500),
+	(84, 272500),
+	(85, 292500),
+	(86, 312500),
+	(87, 332500),
+	(88, 352500),
+	(89, 372500),
+	(90, 392500),
+	(91, 863550),
+	(92, 949905),
+	(93, 1044895),
+	(94, 1149385),
+	(95, 1264323);
+
+/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
+/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
+/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;

+ 8 - 97
EQ2/source/WorldServer/Player.cpp

@@ -97,7 +97,7 @@ Player::Player(){
 	guild = 0;
 	following = false;
 	combat_target = 0;
-	InitXPTable();
+	//InitXPTable();
 	pending_deletion = false;
 	spawn_vis_struct = 0;
 	spawn_pos_struct = 0;
@@ -4091,9 +4091,9 @@ void Player::SetNeededXP(){
 	int16 level = GetLevel() + 1;
 	// If next level is beyond what we have in the map multiply the last value we have by how many levels we are over plus one
 	if (level > 95)
-		SetNeededXP(m_levelXPReq[95] * ((level - 95) + 1));
+		SetNeededXP(database.GetMysqlExpCurve(95)* ((level - 95) + 1));
 	else
-		SetNeededXP(m_levelXPReq[level]);
+		SetNeededXP(database.GetMysqlExpCurve(level));
 }
 
 void Player::SetXP(int32 val){
@@ -6404,100 +6404,11 @@ void Player::SaveHistory() {
 }
 
 void Player::InitXPTable() {
-	m_levelXPReq[2] = 600;
-	m_levelXPReq[3] = 800;
-	m_levelXPReq[4] = 1000;
-	m_levelXPReq[5] = 1400;
-	m_levelXPReq[6] = 1800;
-	m_levelXPReq[7] = 2200;
-	m_levelXPReq[8] = 2600;
-	m_levelXPReq[9] = 3000;
-	m_levelXPReq[10] = 3400;
-	m_levelXPReq[11] = 3800;
-	m_levelXPReq[12] = 4200;
-	m_levelXPReq[13] = 4600;
-	m_levelXPReq[14] = 5000;
-	m_levelXPReq[15] = 5500;
-	m_levelXPReq[16] = 6000;
-	m_levelXPReq[17] = 6500;
-	m_levelXPReq[18] = 7000;
-	m_levelXPReq[19] = 7500;
-	m_levelXPReq[20] = 8000;
-	m_levelXPReq[21] = 8500;
-	m_levelXPReq[22] = 9000;
-	m_levelXPReq[23] = 9500;
-	m_levelXPReq[24] = 10000;
-	m_levelXPReq[25] = 10500;
-	m_levelXPReq[26] = 11000;
-	m_levelXPReq[27] = 11750;
-	m_levelXPReq[28] = 12500;
-	m_levelXPReq[29] = 13250;
-	m_levelXPReq[30] = 14000;
-	m_levelXPReq[31] = 14750;
-	m_levelXPReq[32] = 15500;
-	m_levelXPReq[33] = 16250;
-	m_levelXPReq[34] = 17000;
-	m_levelXPReq[35] = 17750;
-	m_levelXPReq[36] = 18500;
-	m_levelXPReq[37] = 19250;
-	m_levelXPReq[38] = 20000;
-	m_levelXPReq[39] = 20750;
-	m_levelXPReq[40] = 21500;
-	m_levelXPReq[41] = 22250;
-	m_levelXPReq[42] = 23000;
-	m_levelXPReq[43] = 24000;
-	m_levelXPReq[44] = 25000;
-	m_levelXPReq[45] = 26000;
-	m_levelXPReq[46] = 27000;
-	m_levelXPReq[47] = 28000;
-	m_levelXPReq[48] = 29250;
-	m_levelXPReq[49] = 30500;
-	m_levelXPReq[50] = 32000;
-	m_levelXPReq[51] = 33750;
-	m_levelXPReq[52] = 35750;
-	m_levelXPReq[53] = 38000;
-	m_levelXPReq[54] = 40500;
-	m_levelXPReq[55] = 42500;
-	m_levelXPReq[56] = 45500;
-	m_levelXPReq[57] = 48500;
-	m_levelXPReq[58] = 51500;
-	m_levelXPReq[59] = 54500;
-	m_levelXPReq[60] = 57500;
-	m_levelXPReq[61] = 60500;
-	m_levelXPReq[62] = 63500;
-	m_levelXPReq[63] = 66500;
-	m_levelXPReq[64] = 70000;
-	m_levelXPReq[65] = 73500;
-	m_levelXPReq[66] = 77000;
-	m_levelXPReq[67] = 80500;
-	m_levelXPReq[68] = 84000;
-	m_levelXPReq[69] = 87500;
-	m_levelXPReq[70] = 91000;
-	m_levelXPReq[71] = 94500;
-	m_levelXPReq[72] = 98000;
-	m_levelXPReq[73] = 101500;
-	m_levelXPReq[74] = 105000;
-	m_levelXPReq[75] = 108500;
-	m_levelXPReq[76] = 116500;
-	m_levelXPReq[77] = 132500;
-	m_levelXPReq[78] = 152500;
-	m_levelXPReq[79] = 172500;
-	m_levelXPReq[80] = 192500;
-	m_levelXPReq[81] = 212500;
-	m_levelXPReq[82] = 232500;
-	m_levelXPReq[83] = 252500;
-	m_levelXPReq[84] = 272500;
-	m_levelXPReq[85] = 292500;
-	m_levelXPReq[86] = 312500;
-	m_levelXPReq[87] = 332500;
-	m_levelXPReq[88] = 352500;
-	m_levelXPReq[89] = 372500;
-	m_levelXPReq[90] = 392500;
-	m_levelXPReq[91] = 863550;
-	m_levelXPReq[92] = 949905;
-	m_levelXPReq[93] = 1044895;
-	m_levelXPReq[94] = 1149385;
-	m_levelXPReq[95] = 1264323;
+    int i = 2;
+    while (i >= 2 && i <= 95) {
+        m_levelXPReq[i] = database.GetMysqlExpCurve(i);
+        i++;
+    }
 }
 
 void Player::SendQuestRequiredSpawns(int32 quest_id){

+ 6 - 2
EQ2/source/WorldServer/Player.h

@@ -1084,6 +1084,10 @@ public:
 	map <int8, vector<TraitData*> >* FocusEffects;
 	mutable std::shared_mutex trait_mutex;
 	std::atomic<bool> need_trait_update;
+
+	void InitXPTable();
+	map<int8, int32> m_levelXPReq;
+
 private:
 	bool reset_mentorship;
 	bool range_attack;
@@ -1176,8 +1180,8 @@ private:
 	void AddSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
 	void RemoveSpellStatus(SpellBookEntry* spell, sint16 value, bool modify_recast = true, int16 recast = 0);
 	void SetSpellEntryRecast(SpellBookEntry* spell, bool modify_recast, int16 recast);
-	void InitXPTable();
-	map<int8, int32> m_levelXPReq;
+//	void InitXPTable();
+//	map<int8, int32> m_levelXPReq;
 
 	//The following variables are for serializing spawn packets
 	PacketStruct* spawn_pos_struct;

+ 8 - 1
EQ2/source/WorldServer/World.cpp

@@ -49,6 +49,8 @@
 #include "RaceTypes/RaceTypes.h"
 #include "LuaInterface.h"
 
+#include "Player.h"
+
 #include <boost/algorithm/string.hpp>
 
 MasterQuestList master_quest_list;
@@ -82,6 +84,7 @@ map<int16, int16> EQOpcodeVersions;
 WorldDatabase database;
 GuildList guild_list;
 Chat chat;
+Player player;
 
 extern ConfigReader configReader;
 extern LoginServer loginserver;
@@ -174,6 +177,10 @@ void World::init(){
 
 	LoadStartingLists();
 	LoadVoiceOvers();
+	
+	LogWrite(WORLD__DEBUG, 1, "World", "-Loading EXP Curve From DB...");
+	player.InitXPTable();
+	LogWrite(WORLD__DEBUG, 1, "World", "-Loading EXP Curve From DB Complete!");
 
 	LogWrite(WORLD__DEBUG, 1, "World", "-Setting system parameters...");
 	Variable* var = variables.FindVariable("gametime");
@@ -217,7 +224,7 @@ void World::init(){
 	LogWrite(RULESYS__DEBUG, 1, "Rules", "-Loading Rule Sets...");
 	database.LoadRuleSets();
 	LogWrite(RULESYS__DEBUG, 1, "Rules", "-Load Rule Sets complete!");
-	
+
 	LoadItemBlueStats();
 	//PopulateTOVStatMap();
 	group_buff_updates.Start(rule_manager.GetGlobalRule(R_Client, GroupSpellsTimer)->GetInt32());

+ 16 - 0
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -8532,4 +8532,20 @@ string WorldDatabase::GetSignMark(int32 char_id, int32 sign_id, char* char_name)
 	}
 
 	return charname;
+}
+
+int32 WorldDatabase::GetMysqlExpCurve(int level) {
+    Query query;
+    MYSQL_ROW row;
+	//this should never happen but just in case.
+	if(!level){
+		level = 95;
+	}
+    MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT exp_needed from exp_per_level where level=%u", level);
+    if (result && mysql_num_rows(result) > 0) {
+        MYSQL_ROW row = mysql_fetch_row(result);
+        return atoi(row[0]);
+    }
+	//return 1 so we dont break shit later divide by 0 and all that.
+    return 1;
 }

+ 2 - 0
EQ2/source/WorldServer/WorldDatabase.h

@@ -647,6 +647,8 @@ public:
 	bool				DeleteSpiritShard(int32 id);
 
 	void				LoadCharacterSpellEffects(int32 char_id, Client *client, int8 db_spell_type);
+
+	int32				GetMysqlExpCurve(int level);
 private:
 	DatabaseNew			database_new;
 	std::map<int32, string>	zone_names;