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 / DisableTouchConversionToMouse.cs
Last active December 18, 2023 21:23 — forked from ulatekh/DisableTouchConversionToMouse.cs
Globally disables the conversion of touch events to mouse events in Windows 10 but forwards button clicks
// Based on ulatekh's code: https://gist.github.com/ulatekh/f37b1a973c7a1b09f18a457e3a4af54a
// I wanted to keep the funcionality but allow button clicks on the touch screen monitor,
// that way the main user can start a custumer feedback window in the touch screen and be able
// to keep working in the main screen without interference from the touch screen.
namespace BlackFox
{
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security;
@fredimachado
fredimachado / field.snippet
Created July 3, 2017 05:14
Visual Studio snippet to create a Unity serializable field
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>field</Title>
<Shortcut>field</Shortcut>
<Description>Code snippet for a Unity serializable field
Language Version: C# 3.0 or higher</Description>
<Author>Fredi Machado</Author>
<SnippetTypes>
@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
{