Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
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
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)
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)))
{-# 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
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.
class Var:
def __init__(self, name):
self.name = name
def execute(self, bindings):
return bindings[self.name]
class ConstInt:
def __init__(self, val):
{-# LANGUAGE AllowAmbiguousTypes, FlexibleInstances, MultiParamTypeClasses, ScopedTypeVariables, TypeApplications, UndecidableInstances #-}
class Lift' m a b where
lift' :: m a -> b
instance (Applicative m) => Lift' m a (m a) where
lift' = id
instance (Applicative m, Lift' m a b) => Lift' m (x -> a) (m x -> b) where
lift' f = lift' . ((<*>) f)