Skip to content

Instantly share code, notes, and snippets.

View fredimachado's full-sized avatar

Fredi Machado fredimachado

View GitHub Profile
@fredimachado
fredimachado / gist:1155894
Created August 19, 2011 02:32
Update realmcharacters table after deleting a char
diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
index c022d81..2afcd86 100755
--- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
@@ -752,6 +752,8 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data)
Player::DeleteFromDB(guid, GetAccountId());
+ LoginDatabase.PExecute("UPDATE realmcharacters SET numchars = numchars - 1 WHERE acctid = '%d' AND realmid = '%d'", GetAccountId(), realmID);
+
@fredimachado
fredimachado / reload_creature.patch
Created August 21, 2011 22:04
reload more creatures with .reload creature_template
diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index 214e624..d6efb6f 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -401,113 +401,117 @@ public:
if (!*args)
return false;
- uint32 entry = (uint32) atoi((char*)args);
- QueryResult result = WorldDatabase.PQuery("SELECT difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction_A, faction_H, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resis
@fredimachado
fredimachado / gm_island_access.patch
Created December 2, 2011 13:02
Prevent player from accessing GM Island unless if summoned by a GM
diff --git a/sql/custom/gm_island_access.sql b/sql/custom/gm_island_access.sql
new file mode 100644
index 0000000..55be6b9
--- /dev/null
+++ b/sql/custom/gm_island_access.sql
@@ -0,0 +1,11 @@
+SET @NO_MANS_LAND := 42202;
+SET @EXCLUDE_PERSUADED := -73954;
+SET @GM_ISLAND := 876;
+
@fredimachado
fredimachado / updatezone.patch
Created December 19, 2011 13:25
Implement PlayerScript::OnUpdateZone Hook
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index b59c8c0..961079a 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -7379,6 +7379,8 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
if (!zone)
return;
+ sScriptMgr->OnPlayerUpdateZone(this, newZone, newArea);
+
@fredimachado
fredimachado / disables.patch
Created January 11, 2012 20:05
Implement spell disables in Arenas and/or Battlegrounds
diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp
index d7a769d..977d6ca 100755
--- a/src/server/game/Conditions/DisableMgr.cpp
+++ b/src/server/game/Conditions/DisableMgr.cpp
@@ -283,6 +283,18 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
if ((spellFlags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) ||
(unit->GetTypeId() == TYPEID_UNIT && ((unit->ToCreature()->isPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE)))
{
+ if (spellFlags & (SPELL_DISABLE_ARENAS | SPELL_DISABLE_BATTLEGROUNDS))
+ {
@fredimachado
fredimachado / gist:1636773
Created January 19, 2012 00:36
4.2.2 14545
// Handler: 6C7260 - http://paste2.org/p/1874034
[Parser(Opcode.TEST_422_13022, ClientVersionBuild.V4_2_2_14545)]
public static void Handle13022(Packet packet)
{
var bytes = new byte[8];
bytes[0] = (byte)(packet.ReadBit() ? 1 : 0);
bytes[4] = (byte)(packet.ReadBit() ? 1 : 0);
bytes[5] = (byte)(packet.ReadBit() ? 1 : 0);
bytes[1] = (byte)(packet.ReadBit() ? 1 : 0);
diff --git a/Formulas.cs b/Formulas.cs
index f65d65c..fabc88b 100644
--- a/Formulas.cs
+++ b/Formulas.cs
@@ -372,6 +372,44 @@ namespace OpcodeTools
{
return ((opcode & 0x8000) >> 13) | ((opcode & 0x80) >> 7) | ((opcode & 0x800) >> 10);
}
+ }
+
@fredimachado
fredimachado / VertexColor.shader
Last active October 4, 2017 00:59
Coloring each triangle using vertex colors
Shader "Custom/Vertex Color"
{
CGINCLUDE
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "Lighting.cginc"
ENDCG
SubShader
{
@fredimachado
fredimachado / Delete-Duplicate-Fortnite-Replays.ps1
Last active November 14, 2018 11:04
Delete duplicate Fortnite replay files based on the date on the file name
# !! USE IT AT YOUR OWN RISK !!
#
# Run this script after Fixing the replay files and making sure you can watch them in the game
# This script will delete duplicate replay files based on the date on the name of the file
#
# Script to fix replay files: https://gist.github.com/fredimachado/19a489f6dccdb9e2d18b482bed87059d
#
# Copy all this content, paste in notepad and save as a ps1 file, example: Delete-Duplicate-Fortnite-Replays.ps1
# Then, open the folder containing the script, right click it and choose: Run With Powershell
# If it doesnt run, follow this: https://superuser.com/questions/106360/how-to-enable-execution-of-powershell-scripts