Skip to content

Instantly share code, notes, and snippets.

View gist:1321b34187e8e03381903b7cdd55b8b8
Documentation
The behavior of the NormalDialog is interesting. The method displays a messagebox but, the contents of the message box are based around a total of 10 parameters. Here is an example:
NormalDialog(msg, DIALOG_OKAY, -1, -1, -1, 0, -1, 0, -1, 0);
The first input is a message with the data type of char, and the remainder of the parameters are integers. Each aspect of the function can be altered by changing those numbers.
View Main.hs
{-# LANGUAGE TypeOperators, GADTs, Strict #-}
module Main where
data (:+:) f g a = Inl !(f a) | Inr !(g a)
data A
data B
data Foo l where
View intersect.py
def normalize_interval(a, b):
if a <= b: return (a, b)
else: return (a, a)
# good version
def intersect(oth):
return interval(normalize_interval(min(self.hi, oth,hi), max(self.low, oth.low)))
View interval.py
class interval:
def init(low, hi):
self.low = low
self.hi = hi
# bad version
def intersect(oth):
if self.low <= oth.low:
if self.hi < oth.low:
return interval(0,0)
View Refactoring animation code using coroutines
Original inspiration (verbatim code):
void combatManager::ArcShot(icon *icn, int fromX, int fromY, int targX, int targY)
{
bool firingLeft = false;
if (fromX > targX)
firingLeft = true;
int imageIdx = 0; // changes the sprite when its angle changes
// temporarily save the screen so we can clear it from the projectile sprite later
@jkoppel
jkoppel / iconWidget::Main
Created Oct 10, 2017
Find the rectangles
View iconWidget::Main
signed int __thiscall iconWidget::Main(iconWidget *this, tag_message *evt)
{
iconWidget *thisa; // esi@1
__int16 v3; // cx@1
signed int result; // eax@4
INPUT_EVENT_CODE evtCode; // edx@6
heroWindow *parent; // ebp@14
__int16 xRelParent; // ax@14
__int16 yRelParent; // bx@14
resource *v9; // ST00_4@36
@jkoppel
jkoppel / army::Walk
Created Oct 10, 2017
Find the rectangles!
View army::Walk
void army::Walk(signed int dir, int last, int notFirst) {
int targCell = this->GetAdjacentCellIndex(this->occupiedHex, dir);
gCloseMove = IsCloseMove(targCell);
// Bridge opening
if (this->owningSide == 1
&& gpCombatManager->isCastleBattle
&& (targCell == 58 || targCell == 59 || targCell == 60 && this->owningSide == 1 && this->creature.creature_flags & TWO_HEXER)
&& gpCombatManager->drawBridgePosition == BRIDGE_CLOSED) {
this->animationType = ANIMATION_TYPE_STANDING;
@jkoppel
jkoppel / InitMenuHandler
Created Oct 10, 2017
Challenge: Find the use of rectangles
View InitMenuHandler
signed int __thiscall InitMenuHandler(tag_message *msg)
{
signed int result; // eax@26
int v2; // ST48_4@29
int v3; // [sp+Ch] [bp-24h]@27
signed int v5; // [sp+1Ch] [bp-14h]@40
signed int v6; // [sp+20h] [bp-10h]@4
signed int v7; // [sp+24h] [bp-Ch]@1
int highID; // [sp+2Ch] [bp-4h]@32
signed int highIDa; // [sp+2Ch] [bp-4h]@40
@jkoppel
jkoppel / debug.cpp
Created Oct 9, 2017
Example of making debug output in Ironfist
View debug.cpp
extern int __fastcall InitMenuHandler_orig(struct tag_message & msg);
extern font* smallFont;
extern font* bigFont;
extern heroWindow* gpInitWin;
extern void __fastcall FillBitmapArea(class bitmap *, int, int, int, int, int);
int __fastcall InitMenuHandler(struct tag_message & msg) {
if (msg.eventCode == INPUT_MOUSEMOVE_EVENT_CODE) {
View HowAreEqualityConstraintsCompiled.hs
{-# LANGUAGE GADTs #-}
module HowAreEqualityConstraintsCompiled where
data TypeEq a b where
Refl :: (a ~ b) => TypeEq a b