Skip to content

Instantly share code, notes, and snippets.

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 October 10, 2017 08:02
Find the rectangles
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 October 10, 2017 07:50
Find the rectangles!
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 October 10, 2017 07:31
Challenge: Find the use of rectangles
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 October 9, 2017 20:24
Example of making debug output in Ironfist
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) {
{-# LANGUAGE GADTs #-}
module HowAreEqualityConstraintsCompiled where
data TypeEq a b where
Refl :: (a ~ b) => TypeEq a b
{-# LANGUAGE GADTs, TypeOperators, DeriveFunctor, DataKinds, KindSignatures, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, OverlappingInstances, TypeFamilies, UndecidableInstances, FunctionalDependencies, ScopedTypeVariables #-}
module ConstMemDlc where
import qualified Data.Map as Map
import Data.Proxy
import GHC.TypeLits
import Data.Type.Equality
@jkoppel
jkoppel / jnettool.py
Created September 16, 2017 19:17
Example from Raymond Hettinger's talk, "Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015"
# From "Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015"
# Bad code
import jnettools.toolselements.NetworkElement, \
jnettools.tools.Routing, \
jnettools.tools.RouteInspector
ne=jnettools.tools.elements.NetworkElement( '171.0.2.45' )
try:
adt Prog {
Var1 {}
Var2 {}
Const {int val; }
Add { Prog left; Prog right; }
Mul { Prog left; Prog right; }
}
int interpret(Prog prog, int x, int y) {
switch(prog) {
data Exp = Lit String
pprint :: Exp -> String
pprint = (\(Lit s) -> a ++ "'" ++ s ++ "'") where a free
pprint = (\(Lit s) -> a ++ "\"" ++ s ++ "\"") where a free
parse :: String -> (Exp, Exp -> String)
parse s | s =:= f x = (x, f)
where
f = pprint