Skip to content

Commit

Permalink
Merge branch 'dev/master-improvements' into dev/master
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBitz committed Jul 20, 2021
2 parents 9c3a91b + ed9e77d commit eb197d0
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 25 deletions.
66 changes: 57 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Execute gameserver actions in realtime with a simple `INSERT` query into `SRO_VT

### Examples

1. Adds item(s) to the inventory from character
1. Adds item(s) to the inventory from player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Action_ID,
CharName16,
Param01, -- CodeName
Param02, -- Amount
Param03, -- Randomize stats
Param03, -- Random stats (0 = Clean, 1 = Random)
Param04 -- Plus
)
VALUES
Expand All @@ -36,7 +36,7 @@ VALUES
);
```

2. Updates the gold amount from character by increasing (positive) or decreasing (negative)
2. Updates the gold amount from player by increasing (positive) or decreasing (negative)
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -52,7 +52,7 @@ VALUES
);
```

3. Updates the Hwan level (Berserk rank) from character by level
3. Updates the Hwan level (Berserk title) from player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -68,7 +68,7 @@ VALUES
);
```

4. Moves the character to the position on map
4. Moves the player to the position on map
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -90,7 +90,7 @@ VALUES
);
```

5. Moves the character to the position on map through game world id
5. Moves the player to the position on map through game world id
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -114,7 +114,7 @@ VALUES
);
```

6. Drops an item near character
6. Drops an item near player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand Down Expand Up @@ -152,7 +152,7 @@ VALUES
);
```

8. Force reloading the character information by teleporting it on the same place
8. Force reloading the player information by teleporting it on the same place
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -166,7 +166,7 @@ VALUES
);
```

9. Adds a buff to the character. The duration will not be lost through teleports
9. Adds a buff to the player. The duration will not be lost through teleports
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand Down Expand Up @@ -282,6 +282,54 @@ VALUES
);
```

15. Set the life state from player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Action_ID,
CharName16,
Param02 -- Life State (0 = Dead, 1 = Alive)
)
VALUES
(
15,
'JellyBitz',
0 -- Dead
);
```

16. Updates level experience from player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Action_ID,
CharName16,
Param02 -- Level Experience
)
VALUES
(
16,
'JellyBitz',
1000000 -- Increase experience by 1m
);
```

17. Add skill points experience to player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Action_ID,
CharName16,
Param02 -- Skill Points Experience
)
VALUES
(
17,
'JellyBitz',
1000000 -- Increase experience by 1m (equivalent to 2500 SP)
);
```

### Action Result Code

```C++
Expand Down
56 changes: 53 additions & 3 deletions vSRO-GameServer/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void AppManager::InitConfigFile()
ini.SetLongValue("Server", "PENALTY_DROP_PROBABILITY", 5, "; % Probability to drop an item when a player dies");
ini.SetLongValue("Server", "PK_LEVEL_REQUIRED", 20, "; Level required to kill other player");
ini.SetLongValue("Server", "NPC_RETURN_DEAD_LEVEL_MAX", 20, "; Maximum level for using \"Return to last dead point\" from NPC Guide");
ini.SetLongValue("Server", "BEGINNER_MARK_LEVEL_MAX", 19, "; Maximum level to show the beginner mark");
ini.SetLongValue("Job", "LEVEL_MAX", 7, "; Maximum level that can be reached on job suit");
ini.SetLongValue("Race", "CH_TOTAL_MASTERIES", 330, "; Masteries amount Chinese will obtain");
ini.SetLongValue("Guild", "MEMBERS_LIMIT_LEVEL1", 15, "; Guild members capacity at level 1");
Expand Down Expand Up @@ -81,6 +82,7 @@ void AppManager::InitConfigFile()
ini.SetBoolValue("Fix", "DISABLE_GREEN_BOOK", true, "; Disable buff with the green book");
ini.SetBoolValue("Fix", "DISABLE_MSGBOX_SILK_GOLD_PRICE", true, "; Disable messages about \"register silk/gold price.\"");
ini.SetBoolValue("Fix", "EXCHANGE_ATTACK_CANCEL", true, "; Remove attack cancel when player exchanges");
ini.SetBoolValue("Fix", "EXPLOIT_INVISIBLE_INVINCIBLE", true, "; Cancel exploit sent from client (0x70A7)");
// App
ini.SetBoolValue("App", "DEBUG_CONSOLE", true, "; Attach debug console");
// Save it
Expand Down Expand Up @@ -191,8 +193,6 @@ void AppManager::InitPatchValues()
// Stall
WriteMemoryValue<uint8_t>(0x00471B00 + 2, newValue >> 32);
WriteMemoryValue<uint32_t>(0x00471B07 + 1, newValue);
WriteMemoryValue<uint8_t>(0x00471B00 + 2, newValue >> 32);
WriteMemoryValue<uint32_t>(0x00471B07 + 1, newValue);
WriteMemoryValue<uint8_t>(0x00472FF5 + 2, newValue >> 32);
WriteMemoryValue<uint32_t>(0x00473008 + 1, newValue);
WriteMemoryValue<uint8_t>(0x0047ABD8 + 2, newValue >> 32);
Expand Down Expand Up @@ -240,6 +240,13 @@ void AppManager::InitPatchValues()
printf(" - SERVER_NPC_RETURN_DEAD_LEVEL_MAX (%d) -> (%d)\r\n", byteValue, newValue);
WriteMemoryValue<uint8_t>(0x004F36F3 + 1, newValue);
}
if (ReadMemoryValue<uint8_t>(0x004E4F0F + 4, byteValue))
{
uint8_t newValue = ini.GetLongValue("Server", "BEGINNER_MARK_LEVEL_MAX", 19);
printf(" - SERVER_BEGINNER_MARK_LEVEL_MAX (%d) -> (%d)\r\n", byteValue, newValue);
WriteMemoryValue<uint8_t>(0x004E4F0F + 4, newValue);
WriteMemoryValue<uint8_t>(0x00518B99 + 3, newValue);
}

// Job
if (ReadMemoryValue<uint8_t>(0x0060DE69 + 3, byteValue))
Expand Down Expand Up @@ -334,6 +341,7 @@ void AppManager::InitPatchValues()
WriteMemoryValue<uint32_t>(0x005DD36A + 1, newValue);
WriteMemoryValue<uint32_t>(0x00651C7A + 2, newValue);
}

// Alchemy
if (ReadMemoryValue<uint8_t>(0x0052ADAA + 6, byteValue))
{
Expand Down Expand Up @@ -440,6 +448,12 @@ void AppManager::InitPatchValues()
for(int i = 0; i < 2; i++)
WriteMemoryValue<uint8_t>(0x00515578 + i, 0x90); // NOP call
}
if (ini.GetBoolValue("Fix", "EXPLOIT_INVISIBLE_INVINCIBLE", true))
{
printf(" - FIX_EXPLOIT_INVISIBLE_INVINCIBLE\r\n");
for (int i = 0; i < 2; i++)
WriteMemoryValue<uint8_t>(0x00515B78 + i, 0x90); // NOP jnz
}
}
void AppManager::InitDatabaseFetch()
{
Expand Down Expand Up @@ -792,12 +806,48 @@ DWORD WINAPI AppManager::DatabaseFetchThread()
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 15: // Set Life State
{
SQLUSMALLINT cParam02;
if (m_dbLink.sqlCmd.GetData(5, SQL_C_USHORT, &cParam02, 0, NULL))
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
if (player)
player->SetLifeState(cParam02 != 0);
else
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 16: // Update Experience
{
SQLBIGINT cParam02;
if (m_dbLink.sqlCmd.GetData(5, SQL_C_SBIGINT, &cParam02, 0, NULL))
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
if (player)
player->UpdateExperience(cParam02);
else
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 17: // Add Skill Point Experience
{
SQLUINTEGER cParam02;
if (m_dbLink.sqlCmd.GetData(5, SQL_C_ULONG, &cParam02, 0, NULL))
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
if (player)
player->AddSPExperience(cParam02);
else
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 3312: // For testing references
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
if (player)
{
std::cout << " - CGObjPC ptr: " << player << std::endl;
std::cout << " - CGObjPC ptr: " << player << "\r\n Unique Id: " << player->GetUniqueId() << "\r\n";
}
else
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
Expand Down
14 changes: 12 additions & 2 deletions vSRO-GameServer/Silkroad/Object/CGObj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ void CGObj::GetGameWorldId(uint32_t* OutGameWorldId)
{
CallVirtual<void(__thiscall*)(CGObj*, uint32_t*)>(this, 5)(this, OutGameWorldId);
}
void CGObj::SetLifeState(uint8_t State)
uint32_t CGObj::GetUniqueId()
{
CallVirtual<void(__thiscall*)(CGObj*, uint8_t, int, float)>(this, 124)(this, State, 255, 0);
return m_UniqueId;
}
/* Public Methods */
void CGObj::SetLifeState(bool Alive)
{
SetLifeState(Alive ? 1 : 2, 0, 0);
}
/* Private Helpers */
void CGObj::SetLifeState(uint8_t State, int32_t Unknown01, float Unknown02)
{
CallVirtual<void(__thiscall*)(CGObj*, uint8_t, int32_t, float)>(this, 124)(this, State, Unknown01, Unknown02);
}
14 changes: 11 additions & 3 deletions vSRO-GameServer/Silkroad/Object/CGObj.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
class CGObj
{
protected: /// Protected Members
uint32_t ptrVTable;
uint32_t m_ptrVTable;
// Unique Identifier
uint32_t m_UniqueId;
public: /// Public Properties
// Gets the game world id as reference
void GetGameWorldId(uint32_t* OutGameWorldId);
// Set health status
void SetLifeState(uint8_t State);
// Get unique identifier from this object
uint32_t GetUniqueId();
public: // Public Methods
// Set life state
void SetLifeState(bool Alive);
private: /// Private Helpers
// Set life state
void SetLifeState(uint8_t State, int32_t Unknown01, float Unknown02);
};
18 changes: 13 additions & 5 deletions vSRO-GameServer/Silkroad/Object/CGObjPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
#include "../../Silkroad/Text/GString.h"

/* Public Properties */
uint32_t CGObjPC::GetUniqueID()
{
return m_UniqueID;
}
uint32_t CGObjPC::GetCharID()
{
return m_CInstancePC->CharID;
Expand All @@ -24,12 +20,24 @@ uint16_t CGObjPC::AddItem(const char* Codename, int32_t Amount, bool RandomizeSt
}
void CGObjPC::UpdateGold(int64_t Offset)
{
UpdateGold(Offset, 25, true, true);
// Check if offset is higher than int.MaxValue to avoid send a bugged message
if(Offset > 0x7FFFFFFF)
UpdateGold(Offset, 25, true, false);
else
UpdateGold(Offset, 25, true, true);
}
void CGObjPC::UpdateHwan(uint8_t Level)
{
reinterpret_cast<void(__thiscall*)(CGObjPC*, uint8_t)>(0x004A9F40)(this, Level);
}
void CGObjPC::UpdateExperience(int64_t ExpOffset)
{
CallVirtual<void(__thiscall*)(CGObjPC*, uint32_t, int64_t, uint32_t, std::uintptr_t*)>(this, 92)(this, m_UniqueId, ExpOffset, 0, nullptr);
}
void CGObjPC::AddSPExperience(uint32_t SPExpOffset)
{
CallVirtual<void(__thiscall*)(CGObjPC*, uint32_t, int64_t, uint32_t, std::uintptr_t*)>(this, 92)(this, m_UniqueId, 0, SPExpOffset, nullptr);
}
void CGObjPC::UpdateSP(int32_t Offset)
{
CallVirtual<void(__thiscall*)(CGObjPC*, int32_t, int8_t)>(this, 93)(this, Offset, 1);
Expand Down
8 changes: 5 additions & 3 deletions vSRO-GameServer/Silkroad/Object/CGObjPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
class CGObjPC : public CGObjChar
{
private: /// Private Members
uint32_t m_UniqueID;
char pad_0x8[44];
CInstancePC* m_CInstancePC;
char pad_0x38[76];
CPosition m_Position;
public: /// Public Properties
uint32_t GetUniqueID();
// Gets the CharId from database
uint32_t GetCharID();
// Gets the current position
Expand All @@ -25,8 +23,12 @@ class CGObjPC : public CGObjChar
void UpdateGold(int64_t Offset);
// Update hwan title by level
void UpdateHwan(uint8_t Level);
// Update the current SP Experience
// Update the current Skill Points
void UpdateSP(int32_t Offset);
// Update level experience
void UpdateExperience(int64_t ExpOffset);
// Add skill experience
void AddSPExperience(uint32_t SPExpOffset);
// Updates the HP and MP
void UpdateHPMP(int32_t Health, int32_t Mana, uint16_t DisplayEffectType);
// Moves the player to the map location. Return success
Expand Down

0 comments on commit eb197d0

Please sign in to comment.