If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

Fruit Ninja (iOS)

From The Cutting Room Floor
Jump to navigation Jump to search

Title Screen

Fruit Ninja

Developer: Halfbrick Studios
Publisher: Halfbrick Studios
Platforms: iOS, Android
Released internationally: April 21, 2010 (iOS), September 17, 2010 (Android)


SourceIcon.png This game has uncompiled source code.
DevMessageIcon.png This game has a hidden developer message.
DevTextIcon.png This game has hidden development-related text.


Fruit Ninja is everyone's favorite game about murdering fruit.

Developer Comments

Seems to have changed from _SCORE to _KILLED in 1.7... not sure exactly why since Steve 
isn't here, but only need one leaderboard for total sliced
These are the lite achievements. The same things are defined for SD and HD Lite versions, 
with provider ids below  mik - Game Centre automagically gives you weekly friends 
leaderboards so that's why they differ to OF  SD on normal OF doesn't have the zen and 
classic weekly scores, so we just don't specify them
These achievements are specific to a product or platform combination.

Several developer comments can be found in socialnetworks.xml


RENDERING_API_mismatch_between_modules___shouldnt_be_GLES2

A function name present in the executable.

Debug Menu

Hmmm...
To do:
Figure out how to access the debug menu.
UNLOCK BLADES & BACKGROUNDS
ADD 10000 STARFRUIT
RELOCK BLADES & BACKGROUNDS
LANGUAGE SWITCH
iCloud Options
Achievement Helpers
WIPE ALL SAVE DATA
BNET SEND JUNK DATA
BNET PERFORM SYNC
FORCE ADS
RELOCK BEINTOO OFFER
BACK
BACK
NOTHING BUT PLUMS
spawn pomegranate
spawn starfruit
Spawn a Dragonfruit
NOTHING BUT STRAWBERRIES
NOTHING BUT MANGOES
MAKE SCORE 69
MAKE SCORE 99
NOTHING BUT BANANAS
NOTHING BUT PINEAPPLES
MAKE SCORE 208
NOTHING BUT WATERMELONS
NOTHING BUT pASSIONFRUIT
NOTHING BUT PEACHES
MANY POWER BANANAS
FORCE ICLOUD SYNC
SEND iCLOUD GARBAGE
WIPE ICLOUD
CURRENT LANGUAGE:
INSERT LANGUAGE HERE
EXAMPLE STRING:

Text for a debug menu exists in debugMenu.uiscreen. It is currently unknown how to enable it, but...

TouchMove_X0:	TouchAxisX1;		move
TouchMove_X1:	TouchAxisX2;		move
TouchMove_X2:	TouchAxisX3;		move
TouchMove_X3:	TouchAxisX4;		move
TouchMove_X4:	TouchAxisX5;		move
TouchMove_X5:	TouchAxisX6;		move
TouchMove_X6:	TouchAxisX7;		move
TouchMove_X7:	TouchAxisX8;		move
TouchMove_X8:	TouchAxisX9;		move
TouchMove_X9:	TouchAxisX10;		move
TouchMove_X10:	TouchAxisX11;		move
TouchMove_X11:	TouchAxisX12;		move
TouchMove_X12:	TouchAxisX13;		move
TouchMove_X13:	TouchAxisX14;		move
TouchMove_X14:	TouchAxisX15;		move
TouchMove_X15:	TouchAxisX16;		move
TouchMove_Y0:	TouchAxisY1;		move
TouchMove_Y1:	TouchAxisY2;		move
TouchMove_Y2:	TouchAxisY3;		move
TouchMove_Y3:	TouchAxisY4;		move
TouchMove_Y4:	TouchAxisY5;		move
TouchMove_Y5:	TouchAxisY6;		move
TouchMove_Y6:	TouchAxisY7;		move
TouchMove_Y7:	TouchAxisY8;		move
TouchMove_Y8:	TouchAxisY9;		move
TouchMove_Y9:	TouchAxisY10;		move
TouchMove_Y10:	TouchAxisY11;		move
TouchMove_Y11:	TouchAxisY12;		move
TouchMove_Y12:	TouchAxisY13;		move
TouchMove_Y13:	TouchAxisY14;		move
TouchMove_Y14:	TouchAxisY15;		move
TouchMove_Y15:	TouchAxisY16;		move
TouchDown_0:	Touch1;		down
TouchDown_1:	Touch2;		down
TouchDown_2:	Touch3;		down
TouchDown_3:	Touch4;		down
TouchDown_4:	Touch5;		down
TouchDown_5:	Touch6;		down
TouchDown_6:	Touch7;		down
TouchDown_7:	Touch8;		down
TouchDown_8:	Touch9;		down
TouchDown_9:	Touch10;	down
TouchDown_10:	Touch11;		down
TouchDown_11:	Touch12;		down
TouchDown_12:	Touch13;		down
TouchDown_13:	Touch14;		down
TouchDown_14:	Touch15;		down
TouchDown_15:	Touch16;		down
TouchReleased_0:	Touch1;		released
TouchReleased_1:	Touch2;		released
TouchReleased_2:	Touch3;		released
TouchReleased_3:	Touch4;		released
TouchReleased_4:	Touch5;		released
TouchReleased_5:	Touch6;		released
TouchReleased_6:	Touch7;		released
TouchReleased_7:	Touch8;		released
TouchReleased_8:	Touch9;		released
TouchReleased_9:	Touch10;	released
TouchReleased_10:	Touch11;		released
TouchReleased_11:	Touch12;		released
TouchReleased_12:	Touch13;		released
TouchReleased_13:	Touch14;		released
TouchReleased_14:	Touch15;		released
TouchReleased_15:	Touch16;		released
PointerMove:	MouseAxisX,MouseAxisY;		move
PointerPressed:		MouseButton1;		pressed
PointerReleased:	MouseButton1;		released
PointerMove:	X360_LStick_AxisY;		active
PointerMove:	X360_LStick_AxisX;		active
PointerPressedX:		X360_A;		down
ShowDebug:			D;    pressed
ShowCollision:		C;    pressed
Particles:			P;		pressed
Fruit:				F;    pressed
PageUpPressed:		PgUp;	pressed
PageDownPressed:	PgDn;	pressed
ParticlesUp:		Up;		pressed
ParticlesDown:		Down;		pressed
PauseGame:			Enter;		pressed
ShowPauseMenu:		AppMenu;	released
ShowPauseMenu:		escape;		released
UpPressed:			Up;		    pressed
DownPressed:		Down;		pressed
LeftPressed:		Left;		pressed
RightPressed:		Right;	pressed
SpacePressed:		Space;	pressed
PowerUpPressed:		M;	pressed
Speed:				S;	pressed
RegressMenu:		escape;		released
QuitPressed:		Q;	pressed
AddCreditPressed:	Y;	pressed
OperatorOptions:	O;	pressed
RemoveTime:			Z;	pressed
AddTime:			A;	pressed
AddStarfruit:		G;	pressed
RemoveStarfruit:	B;	pressed
Launch:	L;	pressed
ForceBanana: b; pressed

...Input.txt mentions that pressing D will show the debug menu, as well as mentioning several other keys that correspond to debugging functions!

Debug Settings

In addition to the debug menu, there is also a file named debugSettings.cfg in the Config folder.

// Debug Settings file
// Get settings like this:
//   game_work.debugConfig.GetValue("value name"). Returns a string, will be empty ("") if not found, never null. so
//   if (strcmp(debugConfig.GetValue("enable_god_mode"), "true") == 0)) is safe.
// This file supports C++ style comments. just like this one.


// Display
display.clearOnNewFrame = 0


// Entities, Fruit
entities.fruit.draw = 1
entities.fruit.update = 1
entities.fruit.drawshadows = 1


// Entities, Bomb
entities.bomb.draw = 1
entities.bomb.update = 1


// BrickUI
brickui.draw_layer_0 = 1
brickui.draw_layer_1 = 1
brickui.draw_layer_4 = 1
brickui.draw_layer_5 = 1
brickui.update = 1


// Backgrounds
background.draw = 1


// Particles
particles.draw = 1
particles.update = 1


// Sound
sound.update = 1


// Music
music.update = 1


// Wavemanager
wavemanager.update = 1



Developer leftovers

Crashlytics properties

The game uses Crashlytics for monitoring crashes and property files are present.

# This file is automatically generated by UpdateCrashlyticsBuildID.py
#
# Generated at 01/19/16 10:08:09

crashlytics.properties files have this generated.

#This file is automatically generated by Crashlytics to uniquely
#identify individual builds of your Android application.
#
#Do NOT modify, delete, or commit to source control!
#
#Fri Sep 25 10:45:23 AEST 2020
version_name=2.8.9
package_name=com.halfbrick.mortar
build_id=19c53261-2568-4bac-8a03-dc51d584b1ca
version_code=55079901
app_name=com.halfbrick.mortar

crashlytics-build.properties was generated for a different app, likely called Mortar.

Source Code

Flurry ad wrapper

Source code for Flurry Web Adapter exists in the game's executable.

/**
* @preserve Copyright 2012 Twitter, Inc.
* @license http://www.apache.org/licenses/LICENSE-2.0.txt
*/
var Hogan={};(function(a){function h(a){return a=String(a===null||a===undefined?"":a),g.test(a)?a.replace(b,"&").replace(c,"<").replace(d,">").replace(e,"'").replace(f,"""):a}a.Template=function j(a,b,c){a&&(this.r=a),this.c=c,this.text=b||""},a.Template.prototype={r:function(a,b,c){return""},v:h,render:function(b,c,d){return this.ri([b],c||{},d)},ri:function(a,b,c){return this.r(a,b,c)},rp:function(a,b,c,d){var e=c[a];return e?(this.c&&typeof e=="string"&&(e=this.c.compile(e)),e.ri(b,c,d)):""},rs:function(a,b,c){var d="",e=a[a.length-1];if(!i(e))return d=c(a,b);for(var f=0;f<e.length;f++)a.push(e[f]),d+=c(a,b),a.pop();return d},s:function(a,b,c,d,e,f,g){var h;return i(a)&&a.length===0?!1:(typeof a=="function"&&(a=this.ls(a,b,c,d,e,f,g)),h=a===""||!!a,!d&&h&&b&&b.push(typeof a=="object"?a:b[b.length-1]),h)},d:function(a,b,c,d){var e=a.split("."),f=this.f(e[0],b,c,d),g=null;if(a==="."&&i(b[b.length-2]))return b[b.length-1];for(var h=1;h<e.length;h++)f&&typeof f=="object"&&e[h]in f?(g=f,f=f[e[h]]):f="";return d&&!f?!1:(!d&&typeof f=="function"&&(b.push(g),f=this.lv(f,b,c),b.pop()),f)},f:function(a,b,c,d){var e=!1,f=null,g=!1;for(var h=b.length-1;h>=0;h--){f=b[h];if(f&&typeof f=="object"&&a in f){e=f[a],g=!0;break}}return g?(!d&&typeof e=="function"&&(e=this.lv(e,b,c)),e):d?!1:""},ho:function(a,b,c,d,e){var f=this.c,g=a.call(b,d,function(a){return f.compile(a,{delimiters:e}).render(b,c)}),h=f.compile(g.toString(),{delimiters:e}).render(b,c);return this.b=h,!1},b:"",ls:function(a,b,c,d,e,f,g){var h=b[b.length-1],i=null;if(!d&&this.c&&a.length>0)return this.ho(a,h,c,this.text.substring(e,f),g);i=a.call(h);if(typeof i=="function"){if(d)return!0;if(this.c)return this.ho(i,h,c,this.text.substring(e,f),g)}return i},lv:function(a,b,c){var d=b[b.length-1],e=a.call(d);return typeof e=="function"&&(e=e.call(d)),e=e.toString(),this.c&&~e.indexOf("{{")?this.c.compile(e).render(d,c):e}};var b=/&/g,c=/</g,d=/>/g,e=/\'/g,f=/\"/g,g=/[&<>\"\']/,i=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"}})(typeof exports!="undefined"?exports:Hogan),function(a){function h(a){a.n.substr(a.n.length-1)==="}"&&(a.n=a.n.substring(0,a.n.length-1))}function i(a){return a.trim?a.trim():a.replace(/^\s*|\s*$/g,"")}function j(a,b,c){if(b.charAt(c)!=a.charAt(0))return!1;for(var d=1,e=a.length;d<e;d++)if(b.charAt(c+d)!=a.charAt(d))return!1;return!0}function k(a,b,c,d){var e=[],f=null,g=null;while(a.length>0){g=a.shift();if(g.tag=="#"||g.tag=="^"||l(g,d))c.push(g),g.nodes=k(a,g.tag,c,d),e.push(g);else{if(g.tag=="/"){if(c.length===0)throw new Error("Closing tag without opener: /"+g.n);f=c.pop();if(g.n!=f.n&&!m(g.n,f.n,d))throw new Error("Nesting error: "+f.n+" vs. "+g.n);return f.end=g.i,e}e.push(g)}}if(c.length>0)throw new Error("missing closing tag: "+c.pop().n);return e}function l(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c].o==a.n)return a.tag="#",!0}function m(a,b,c){for(var d=0,e=c.length;d<e;d++)if(c[d].c==a&&c[d].o==b)return!0}function n(a){return'i = i || "";var b = i + "";var _ = this;'+q(a)+"return b;"}function o(a){return a.replace(f,"\\\\").replace(c,'\\"').replace(d,"\\n").replace(e,"\\r")}function p(a){return~a.indexOf(".")?"d":"f"}function q(a){var b="";for(var c=0,d=a.length;c<d;c++){var e=a[c].tag;e=="#"?b+=r(a[c].nodes,a[c].n,p(a[c].n),a[c].i,a[c].end,a[c].otag+" "+a[c].ctag):e=="^"?b+=s(a[c].nodes,a[c].n,p(a[c].n)):e=="<"||e==">"?b+=t(a[c]):e=="{"||e=="&"?b+=u(a[c].n,p(a[c].n)):e=="\n"?b+=w('"\\n"'+(a.length-1==c?"":" + i")):e=="_v"?b+=v(a[c].n,p(a[c].n)):e===undefined&&(b+=w('"'+o(a[c])+'"'))}return b}function r(a,b,c,d,e,f){return"if(_.s(_."+c+'("'+o(b)+'",c,p,1),'+"c,p,0,"+d+","+e+', "'+f+'")){'+"b += _.rs(c,p,"+'function(c,p){ var b = "";'+q(a)+"return b;});c.pop();}"+'else{b += _.b; _.b = ""};'}function s(a,b,c){return"if (!_.s(_."+c+'("'+o(b)+'",c,p,1),c,p,1,0,0,"")){'+q(a)+"};"}function t(a){return'b += _.rp("'+o(a.n)+'",c,p,"'+(a.indent||"")+'");'}function u(a,b){return"b += (_."+b+'("'+o(a)+'",c,p,0));'}function v(a,b){return"b += (_.v(_."+b+'("'+o(a)+'",c,p,0)));'}function w(a){return"b += "+a+";"}var b=/\S/,c=/\"/g,d=/\n/g,e=/\r/g,f=/\\/g,g={"#":1,"^":2,"/":3,"!":4,">":5,"<":6,"=":7,_v:8,"{":9,"&":10};a.scan=function(c,d){function w(){p.length>0&&(q.push(new String(p)),p="")}function x(){var a=!0;for(var c=t;c<q.length;c++){a=q[c].tag&&g[q[c].tag]<g._v||!q[c].tag&&q[c].match(b)===null;if(!a)return!1}return a}function y(a,b){w();if(a&&x())for(var c=t,d;c<q.length;c++)q[c].tag||((d=q[c+1])&&d.tag==">"&&(d.indent=q[c].toString()),q.splice(c,1));else b||q.push({tag:"\n"});r=!1,t=q.length}function z(a,b){var c="="+v,d=a.indexOf(c,b),e=i(a.substring(a.indexOf("=",b)+1,d)).split(" ");return u=e[0],v=e[1],d+c.length-1}var e=c.length,f=0,k=1,l=2,m=f,n=null,o=null,p="",q=[],r=!1,s=0,t=0,u="{{",v="}}";d&&(d=d.split(" "),u=d[0],v=d[1]);for(s=0;s<e;s++)m==f?j(u,c,s)?(--s,w(),m=k):c.charAt(s)=="\n"?y(r):p+=c.charAt(s):m==k?(s+=u.length-1,o=g[c.charAt(s+1)],n=o?c.charAt(s+1):"_v",n=="="?(s=z(c,s),m=f):(o&&s++,m=l),r=s):j(v,c,s)?(q.push({tag:n,n:i(p),otag:u,ctag:v,i:n=="/"?r-v.length:s+u.length}),p="",s+=v.length-1,m=f,n=="{"&&(v=="}}"?s++:h(q[q.length-1]))):p+=c.charAt(s);return y(r,!0),q},a.generate=function(b,c,d){return d.asString?"function(c,p,i){"+b+";}":new a.Template(new Function("c","p","i",b),c,a)},a.parse=function(a,b){return b=b||{},k(a,"",[],b.sectionTags||[])},a.cache={},a.compile=function(a,b){b=b||{};var c=a+"||"+!!b.asString,d=this.cache[c];return d?d:(d=this.generate(n(this.parse(this.scan(a,b.delimiters),b)),a,b),this.cache[c]=d)}}(typeof exports!="undefined"?exports:Hogan)


//
//  flurry_bridge.js
//  Flurry Web Adapter
//
//  Copyright 2012 Flurry, Inc. All rights reserved.
//	
//	Methods in this header file are for use with Flurry Ads WebView

// constructor, taking the global window object
var flurryBridgeCtor = function(w) {
    var flurryadapter = {};
    // could be private?
    flurryadapter.flurryCallQueue = [ ];
    
    flurryadapter.callComplete = function( cmd ) {
        if ( this.flurryCallQueue.length == 0 ) {
            return;
        }
        var adapterCall = this.flurryCallQueue.splice(0,1)[0];
        this.executeNativeCall(adapterCall);
        return "OK";
    };
    flurryadapter.executeCall = function( command ) {
        var adapterCall = "flurry://flurrycall?event=" + command;
        var value;
        for ( var i = 1; i < arguments.length; i += 2 ) {
            value = arguments[i + 1];
            if ( value == null ) {
                continue;
            }
            adapterCall += "&" + arguments[i] + "=" + escape( value );
        }
        if ( this.flurryCallQueue.length > 0 ) {
            this.flurryCallQueue.push( adapterCall );
        }
        else {
            this.executeNativeCall(adapterCall);
        }
    };
    // also could be private?
    flurryadapter.executeNativeCall = function( adapterCall ) {
        if ( adapterCall.length == 0 ) {
            return;
        }

        var iframe = document.createElement("IFRAME");
        iframe.setAttribute("src", adapterCall);
        document.documentElement.appendChild(iframe);
        iframe.parentNode.removeChild(iframe);
        iframe = null;
    };
    return flurryadapter;
};h�//document.write("<script src=\"mraid.js\"></script>");

var mraidCtor = function(flurryBridge, initState) {
    
	// to be returned
	var mraid = {};
    
	var STATES = mraid.STATES  = {
        LOADING           : 'loading',
        UNKNOWN           : 'unknown', // not in MRAID 1.0 spec?
        DEFAULT           : 'default',
        EXPANDED          : 'expanded',
        HIDDEN            : 'hidden'
	};
    
	var EVENTS = mraid.EVENTS = {
        // where did these other states come from?
        ASSETREADY        : 'assetReady',
        ASSETREMOVED      : 'assetRemoved',
        ASSETRETIRED      : 'assetRetired',
        INFO              : 'info',
        // only the states below are defined in MRAID 1.0 spec
        ERROR             : 'error',
        ORIENTATIONCHANGE : 'orientationChange',
        READY             : 'ready',
        STATECHANGE       : 'stateChange',
        VIEWABLECHANGE    : 'viewableChange'
	};
    
	// private vars
	var listeners = {}; // this is an associative array mapping strings (event names) to lists of either functions or strings
    // {'eventA':[function(e){...}, 'listenerFoo', ...], eventB: ...}
	var currentState = STATES.LOADING; // start out in LOADING state, SDK puts MRAID into DEFAULT state
	var expandProperties = {
    width:initState.width,
    height:initState.height,
    isModal:initState.isModal,
    useCustomClose:false
	};
	var collapseProperties = {};
	var placementType = initState.placementType;
    var disable = false;
    
	// default close button
	var closeId = 'flurry-mraid-default-close';
	var imgUrl = 'http://flurry.cachefly.net/adSpaceStyles/images/bttn-close-bw.png';
    
	var safeClose = function() {
	    try {
	        if(window.mraid) {
	            window.mraid.close();
	        } else if(window.flurryadapter) {
	            flurryadapter.executeCall('adWillClose');
	        } else {
	            console.log('unable to close');
	        }
	    } catch (error) {
	        console.log('unable to close: ' + error);
	    }
	};
    
	var makeDefaultClose = function() {
	    var img = document.createElement('img');
	    img.src = imgUrl;
	    img.id = closeId;
        // we can't use img.onclick or img.addEventListener for 'click' because phluant sdk ruthlessly
        // cleans any event listeners by recreating body content using code like this: a.innerHTML += "".
        // As workaround, we use document.body.addEventListener for 'click' in setupDefaultCloseHandler
        //        img.onclick = safeClose;
	    img.style.position = 'absolute';
	    img.style.top = '10px';
	    img.style.right = '10px';
	    img.style.width = '50px';
	    img.style.height = '50px';
        img.style.zIndex = 10000;
	    return img;
	}
    
     var setupDefaultCloseHandler = function() {
        document.body.addEventListener('click', function(e) {
        e = e || window.event;
        var target = e.target || e.srcElement;
        if (target.id === closeId) {
          safeClose();
        }
       });
  }
    
	var updateDefaultClose = function() {
	    // show default close button only for interstitial or expanded ad with expandProperties.useCustomClose === false
	    if (!expandProperties.useCustomClose && (placementType === 'interstitial' || currentState === STATES.EXPANDED)) {
            addDefaultClose();
        } else {
            removeDefaultClose();
        }
	}
    
	var addDefaultClose = function() {
	    var closeButton = document.getElementById(closeId);
	    if(!closeButton) {
	        closeButton = makeDefaultClose();
	        document.body.appendChild(closeButton);
	    }
	}
    
	var removeDefaultClose = function() {
	    var closeButton = document.getElementById(closeId);
	    if(closeButton) {
            document.body.removeChild(closeButton);
	    }
	}
    
	/*
	 * Checking for the state of the mraid client library and subscribing to the ready event if necessary
	 * When the client library is ready call the showAd method to render the ad
	 */
    
	/* js helper functions */
    
    var contains = function(value, obj) {
        for (var i in obj) {
            if (obj[i] === value) {
                return true;
            }
        }
        return false;
    };
    
    
	var stringify = function(obj) {
        if (typeof obj == 'object') {
            if (obj.push) {
                var out = [];
                for (var p in obj) {
                    if(obj.hasOwnProperty(p)) {
                        out.push(obj[p]);
                    }
                }
                return '[' + out.join(',') + ']';
            } else {
                var out = [];
                for (var p in obj) {
                    if(obj.hasOwnProperty(p)) {
                        out.push('\''+p+'\':'+obj[p]);
                    }
                }
                return '{' + out.join(',') + '}';
            }
        } else {
            return new String(obj);
        }
    };
    
	var broadcastEvent = function() {
		var args = new Array(arguments.length);
		for (var i = 0; i < arguments.length; i++) {
		    args[i] = arguments[i];
		}
		var event = args.shift();
        
		try {
		    if (listeners[event]) {
		        for(var j = 0; j < listeners[event].length; j++) {
		            if(typeof listeners[event][j] === 'function') {
		                listeners[event][j].apply(undefined, args);
		            } else if(typeof listeners[event][j] === 'string' && typeof window[listeners[event][j]] === 'function') {
		                window[listeners[event][j]].apply(undefined, args);
		            }
		        }
			}
		} catch(e) {
		    console.log(e);
		}
	}
    
    mraid.disable = function() {
        removeDefaultClose();
        disable = true;
    }
    
	// Takes an event name (string) and either a function or a string, Registers a listener for this event.
	// String listener is taken to be the name of a global var -- ie a property of window
	mraid.addEventListener = function(event, listener) {
        if (disable) {
            return;
        }
        
	    if (!event || !listener) {
	        broadcastEvent(EVENTS.ERROR, 'Both event and listener are required.', 'addEventListener');
	    } else if (!contains(event, EVENTS)) {
	        broadcastEvent(EVENTS.ERROR, 'Unknown event: ' + event, 'addEventListener');
	    } else {
	        if (!listeners[event]) {
	            listeners[event] = [listener];
	        } else {
	            listeners[event].push(listener);
	        }
	    }
        flurryBridge.executeCall("eventListenerAdded");
	}
    
	mraid.stateChange = function(newState) {
        if (disable) {
            return;
        }
        
	    if(currentState === newState) {
	        return;
	    }
        
	    broadcastEvent(EVENTS.INFO, 'setting state to ' + stringify(newState));
	    var oldState = currentState;
	    currentState = newState;
	    if(oldState === STATES.LOADING && newState === STATES.DEFAULT) {
            setupDefaultCloseHandler();
            updateDefaultClose();
            broadcastEvent(EVENTS.READY);
        } else if(oldState === STATES.HIDDEN || newState === STATES.HIDDEN) {
            broadcastEvent(EVENTS.VIEWABLECHANGE);
        } else if(oldState === STATES.DEFAULT && newState === STATES.EXPANDED) {
            updateDefaultClose();
        } else if(newState === STATES.DEFAULT && oldState === STATES.EXPANDED) {
            updateDefaultClose();
        }
        broadcastEvent(EVENTS.STATECHANGE, currentState);
	}
    
	mraid.close = function () {
        if (disable) {
            return;
        }
        
		// webview should downgrade its state, should also fire the
		// stateChange event.
		// ads in expanded state -> close() -> default
		// ads in default state-> close() -> hidden
	    var state = mraid.getState();
	    if(state === STATES.DEFAULT) {
	        mraid.stateChange(STATES.HIDDEN);
	        flurryBridge.executeCall("adWillClose");
	    } else if(state === STATES.EXPANDED) {
	        mraid.stateChange(STATES.DEFAULT);
	        flurryBridge.executeCall("collapse");
	    } else {
            console.log("close() called in state " + state);
	        // TODO
	    }
	};
    
	mraid.expand = function(url) {
        if (disable) {
            return;
        }
        
        var state = mraid.getState();
	    if(state !== STATES.DEFAULT) {
            console.log("expand() called in state " + state);
	        return;
	    }
	    if(url) {
            flurryBridge.executeCall('expand', 'width', expandProperties.width, 'height', expandProperties.height, 'url', url);
	    } else {
            flurryBridge.executeCall('expand', 'width', expandProperties.width, 'height', expandProperties.height);
	    }
	    mraid.stateChange(STATES.EXPANDED);
	};
    
	mraid.setExpandProperties = function(properties) {
        if (disable) {
            return;
        }
        
	    if(typeof properties.width === 'number' && !isNaN(properties.width)) {
	        expandProperties.width = properties.width;
	    }
	    if(typeof properties.height === 'number' && !isNaN(properties.height)) {
	        expandProperties.height = properties.height
	    }
	    if(typeof properties.useCustomClose === 'boolean') {
	        expandProperties.useCustomClose = properties.useCustomClose;
	        updateDefaultClose();
	    }
	};
    
	mraid.getExpandProperties = function(properties) {
        if (disable) {
            return;
        }
        
	    var ret = {};
	    ret.width = expandProperties.width;
	    ret.height = expandProperties.height;
	    ret.isModal = expandProperties.isModal;
	    ret.useCustomClose = expandProperties.useCustomClose;
	    return ret;
	};
    
	mraid.getPlacementType = function() {
	    return placementType;
	};
    
	/*
	 * The getversion method should return the version of mraid. Since we are 1.0 compliant, should
	 * return 1.0.
	 */
	mraid.getVersion = function () {
        if (disable) {
            return "";
        }
        
		return "1.0";
	};
    
	mraid.getState = function() {
        if (disable) {
            return "";
        }
        
		// the default states are loading, default, expanded, hidden
		// loading: the sdk is not yet ready for interactions with the Controller
		// default: initial position and size of the ad container as placed by app and sdk
		// expanded: the ad container has expanded to cover the app. content at top of view hierarchy
		// hidden: the ad container no longer displays the ad
	    return currentState;
	};
    
	mraid.isViewable = function() {
        if (disable) {
            return false;
        }
        
	    if(mraid.getState() === 'hidden') {
	        return false;
	    } else {
	        return true;
	    }
	};
    
	mraid.open = function(url) {
        if (disable) {
            return;
        }
        
	    try{
	        flurryBridge.executeCall("open", "url", url);
	    } catch (e) {
	        console.log(e);
	    }
	};
    
	// Deregisters the listener for this event
	mraid.removeEventListener = function(event, listener) {
        if (disable) {
            return;
        }
        
	    if (!event) {
	        broadcastEvent('error', 'Must specify an event.', 'removeEventListener');
	    } else {
	        if(listener && (listeners[event])) {
	            for(var i = 0; i < listeners[event].length; i++) {
	                if(listeners[event][i] === listener) {
	                    listeners[event].splice(i,1); // remove listener from array
	                }
	            }
	        }
	        else if (listeners[event]) {
	        	listeners[event] = [];
	        }
	    }
	};
    
	mraid.useCustomClose = function(use) {
        if (disable) {
            return;
        }
        
		// true - ad creative supplies its own designed for the close area
		// false - SDK defualt image should be displayed for the close area
	    if(typeof use === 'boolean') {
	        expandProperties.useCustomClose = use;
	        updateDefaultClose();
	    }
	};
    
	return mraid;
};

Engine leftovers

On Windows 8, the MortarEngine_VS11 folder is present, containing a portion of source files for the Mortar Engine, the proprietary engine used by Halfbrick. The same applies to the root of the free iOS release, excluding that folder.

BlankHeader.txt

// ------------------------------------------------------------------------------------------------
//
//  File: .h
//
//      Description		- 
//      Author			- 
//
//  Modifications:
//  --------------
//      month day, year	- Initial creation.
//
// ------------------------------------------------------------------------------------------------

#ifndef __<FILENAME>_H
#define __<FILENAME>_H

////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								INCLUDES.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////




namespace Mortar
{
	////////////////////////////////////////////////////////////////////////////
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	//								DEFINES.								  //
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	////////////////////////////////////////////////////////////////////////////




	////////////////////////////////////////////////////////////////////////////
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	//								STRUCTURES.								  //
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	////////////////////////////////////////////////////////////////////////////



	////////////////////////////////////////////////////////////////////////////
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	//								CLASSES.								  //
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	////////////////////////////////////////////////////////////////////////////

	class 
	{
	//------------------------------------------------------------------------
	// enums / type defs
	//------------------------------------------------------------------------
	private:
	protected:
	public:


	//------------------------------------------------------------------------
	// Classes
	//------------------------------------------------------------------------
	private:
	protected:
	public:

	//------------------------------------------------------------------------
	// Members
	//------------------------------------------------------------------------
	private:
	protected:
	public:

	//------------------------------------------------------------------------
	// Functions
	//------------------------------------------------------------------------
	private:
	protected:
	public:

	};

	////////////////////////////////////////////////////////////////////////////
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	//								FUNCTIONS.								  //
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	////////////////////////////////////////////////////////////////////////////



	////////////////////////////////////////////////////////////////////////////
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	//								EXTERNALS.								  //
	//------------------------------------------------------------------------//
	//------------------------------------------------------------------------//
	////////////////////////////////////////////////////////////////////////////
}

#endif //__<FILENAME>_H

On the first release:

// ------------------------------------------------------------------------------------------------
//
//  File: .h
//
//      Description     - 
//      Author          - 
//
//  Modifications:
//  --------------
//      month day, year    - Initial creation.
//
// ------------------------------------------------------------------------------------------------

#ifndef _H
#define _H

////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								INCLUDES.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								DEFINES.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								STRUCTURES.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								CLASSES.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////

class 
{
//------------------------------------------------------------------------
// enums / type defs
//------------------------------------------------------------------------
private:
protected:
public:


//------------------------------------------------------------------------
// Classes
//------------------------------------------------------------------------
private:
protected:
public:

//------------------------------------------------------------------------
// Members
//------------------------------------------------------------------------
private:
protected:
public:

//------------------------------------------------------------------------
// Functions
//------------------------------------------------------------------------
private:
protected:
public:

};

////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								FUNCTIONS.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								EXTERNALS.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////

#endif //_H

A template used for headers of source code files.

BlankSource.txt:

// ------------------------------------------------------------------------------------------------
//
//  File: .cpp
//
//      Description     - 
//      Author          - 
//
//  Modifications:
//  --------------
//       month day, year    - Initial creation.
//
// ------------------------------------------------------------------------------------------------


////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								INCLUDES.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								DEFINES.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								STRUCTS.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								VARIABLES.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								STATICS.								  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								LOCAL FUNCTIONS.						  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//								MAIN FUNCTIONS.							  //
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////

//------------------------------------------------------------------------
// Name
//------------------------------------------------------------------------
//
// Shortdesc.
//
//
// Input	- Var1	-	what it does
//			- Var2	-	What it does
//
// Returns	type	what it means
//

A template used for source code files.

Box2D.txt:

To include Box2D in your project, add 3rdParty/Source/Box2D_v2.2.1 to your additional include paths and 3rdParty/Source/Box2D_v2.2.1/lib/$(Platform)/[debug or release]/Box2D.lib to your libs

A note on Box2D support.

Color.inl:

// ------------------------------------------------------------------------------------------------
//
//  File: Colour.inl
//
//      Description     - Implementation of the inline Colour functions
//      Author          - Aidan Millott
//
//  Modifications:
//  --------------
//       July 30, 2009    - Initial creation.
//
// ------------------------------------------------------------------------------------------------

#pragma warning(push)
#pragma warning(disable : 4244)	// TODO: fix this properly so we don't get any "conversion from 'xxx' to 'yyy', possible loss of data" warnings

// Operator +
//
inline Colour Colour::operator + ( const Colour& rhs ) const
{
	return Colour((r + rhs.r), (g + rhs.g), (b + rhs.b),  a/*(s32)(a + rhs.a)*/ );
}

inline Colour Colour::operator + ( kf32 rhs ) const
{
	s32 val = (s32)rhs;
	if(rhs < 1.0f)
	{
		val = (s32)(rhs*255);
	}
	return Colour( (r + val), (g + val),( b + val),a/*(s32)(a + val)*/);
}

// Operator =
//
inline Colour Colour::operator = ( const Colour& rhs )
{
	a = rhs.a;
	r = rhs.r;
	g = rhs.g;
	b = rhs.b;
	return *this;
}

inline Colour Colour::operator = ( kf32 rhs )
{
	a = rhs;
	r = rhs;
	g = rhs;
	b = rhs;
	return *this;
}

// Operator -
//
inline Colour Colour::operator - ( const Colour& rhs ) const
{
	return Colour((r - rhs.r), (g - rhs.g),( b - rhs.b), a /*(s32)(a - rhs.a)*/ );
}

inline Colour Colour::operator - ( kf32 rhs ) const
{
	s32 val = (s32)rhs;
	if(rhs < 1.0f)
	{
		val = (s32)(rhs*255);
	}
	return Colour(( r - val), (g - val),( b - val),a/*(s32)(a - val)*/);
}



// Operator *
//
inline Colour Colour::operator * ( const kf32& rhs ) const
{
	return	Colour
		(
		( r* rhs ),
		( g* rhs ),
		( b* rhs ),
		//(s32)( a* rhs )
		a
		);
}

inline Colour Colour::operator / ( const kf32& rhs ) const
{
	return	Colour
		(
		( r/ rhs ),
		( g/ rhs ),
		( b/ rhs ),
		//(s32)( a/ rhs )
		a
		);
}



// Operator +=
//
inline Colour& Colour::operator += (const Colour& rhs )
{
	r += rhs.r;
	g += rhs.g;
	b += rhs.b;
	//a += rhs.a;

	return *this;
}

inline Colour& Colour::operator += (const kf32 rhs )
{
	s32 val = (s32)rhs;
	if(rhs < 1.0f)
	{
		val = (s32)(rhs*255);
	}


	r += val;
	g += val;
	b += val;
	//a += val;

	return *this;
}

// Operator -=
//
inline Colour& Colour::operator -= ( const Colour& rhs )
{
	r -= rhs.r;
	g -= rhs.g;
	b -= rhs.b;
	//a -= rhs.a;

	return *this;
}

inline Colour& Colour::operator -= ( const kf32 rhs )
{
	s32 val = (s32)rhs;
	if(rhs < 1.0f)
	{
		val = (s32)(rhs*255);
	}


	r -= val;
	g -= val;
	b -= val;
	//a -= val;

	return *this;
}


// Operator *=
//
inline Colour& Colour::operator *= ( const kf32 val )
{
	r = ( r* val );
	g = ( g* val );
	b = ( b* val );
	//a = ( a* val );

	return *this;
}

// Operator /=
inline Colour& Colour::operator /= ( const kf32 val )
{
	r = ( r/ val );
	g = ( g/ val );
	b = ( b/ val );
	//a = ( a/ val );

	return *this;
}


// Operator ==
inline bool Colour::operator == (const Colour &v) const
{
	return (element == v.element);
}


// Operator !=
inline bool Colour::operator != (const Colour &v) const
{
	return (element != v.element);
}

#pragma warning(pop)

Delegates.inl:

// ------------------------------------------------------------------------------------------------
//
//  File: Delegates.inl
//
//      Description		- Implements the Delegate##DELEGATE_PARAM_COUNT class which allow for generic and
//						  flexible function pointers, if you need to add more parameters, please
//						  add them via the #define/#include method used in "Delegates.h"
//
//      Author			- Grant Peters
//
//  Modifications:
//  --------------
//      Sept 8, 2009	- Grant: Copied from my private engine.
//
// ------------------------------------------------------------------------------------------------

#define DELEGATE_DECLARE_NAME			PP_CONCAT(Delegate, DELEGATE_PARAM_COUNT)
#define DELEGATE_DECLARE_FUNC_PARAMS	PP_REPEAT_TEMPLATE_PARAM(DELEGATE_PARAM_COUNT)
#define DELEGATE_DECLARE_FUNC_VALUES	PP_REPEAT_TEMPLATE_VALUE(DELEGATE_PARAM_COUNT)
#define DELEGATE_DECLARE_FUNC_TYPES		PP_REPEAT_TEMPLATE_TYPE(DELEGATE_PARAM_COUNT)


namespace Mortar
{
	template<class ReturnType PP_COMMA_IF(DELEGATE_PARAM_COUNT) PP_REPEAT_TEMPLATE_DECL(DELEGATE_PARAM_COUNT)>
	class DELEGATE_DECLARE_NAME
	{
		struct BaseDelegate;
		typedef StackAllocatedPointer<BaseDelegate, 32> DelegatePointer;

		struct BaseDelegate
		{
			friend class DELEGATE_DECLARE_NAME/*<ReturnType PP_COMMA_IF(DELEGATE_PARAM_COUNT)  DELEGATE_DECLARE_FUNC_TYPES>*/;
			friend class StackAllocatedPointer<BaseDelegate, 32>;
			virtual ~BaseDelegate() {}

		private:
			virtual void Clone(DelegatePointer &ptr) const = 0;
			virtual ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS) = 0;
		};

		DelegatePointer m_delegate;
	public:

		DELEGATE_DECLARE_NAME() {}

		ReturnType operator() (DELEGATE_DECLARE_FUNC_PARAMS) const { return Call(DELEGATE_DECLARE_FUNC_VALUES);	}

		ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS) const
		{
			BaseDelegate *func = m_delegate.Resolve();
			if(func != NULL)
				return func->Call(DELEGATE_DECLARE_FUNC_VALUES);

			// If the program fails to compile at this line, use 'CallNoNullCheck()' instead
			// you should also wrap the code in 'if(Delegate.IsNull())' when doing this so as
			// to handle NULL pointers and AVOID A CRASH!!!
			return ReturnType();	
		}

		// You should also wrap the code in 'if(Delegate.IsNull())' when using this function
		// so as to handle NULL pointers and AVOID A CRASH!!!
		ReturnType CallNoNullCheck (DELEGATE_DECLARE_FUNC_PARAMS) const
		{
			BaseDelegate *func = m_delegate.Resolve();
			ASSERT_MSG(func != NULL, "'Delegate.CallNoNullCheck()' called when the delegate was NULL,\nplease wrap code in an 'if(Delegate.IsNull())' to protect against this scenario!");
			return func->Call(DELEGATE_DECLARE_FUNC_VALUES);
		}

		bool IsNull()
		{
			return m_delegate.Resolve() == NULL;
		}

#pragma region(BaseDelegate assignments)
		void operator=(const BaseDelegate &func)
		{
			func.Clone(m_delegate);
		}
		DELEGATE_DECLARE_NAME(const BaseDelegate &func)
		{
			func.Clone(m_delegate);
		}
#pragma endregion

#pragma region(Static/Global function delegate)
		class Global : public BaseDelegate
		{
		public:
			typedef ReturnType (*FuncPtr)(DELEGATE_DECLARE_FUNC_PARAMS);
			Global(FuncPtr function)
				: m_function(function)
			{
			}

			Global(const Global &copy)
				: m_function(copy.m_function)
			{
			}

		private:
			FuncPtr m_function;

			void Clone(DelegatePointer &ptr) const
			{
				ptr.CopyConstruct(*this);
			}

			ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS)
			{
				return m_function(DELEGATE_DECLARE_FUNC_VALUES);
			}
		};
#pragma region(Assignment helper)
		DELEGATE_DECLARE_NAME(typename Global::FuncPtr globalFunc)
		{
			if(globalFunc != NULL)
				*this = Global(globalFunc);
			else
				m_delegate.Delete();
		}
		void operator=(typename Global::FuncPtr globalFunc)
		{
			if(globalFunc != NULL)
				*this = Global(globalFunc);
			else
				m_delegate.Delete();
		}
#pragma endregion
#pragma endregion

#pragma region(Callee function delegate)
		template<typename CalleeType>
		class Callee : public BaseDelegate
		{
		public:
			typedef ReturnType (CalleeType::*FuncPtr)(DELEGATE_DECLARE_FUNC_PARAMS);

			Callee(CalleeType *callee, FuncPtr function)
				: m_callee(callee), m_function(function)
			{
			}
			Callee(CalleeType &callee, FuncPtr function)
				: m_callee(&callee), m_function(function)
			{
			}

		private:
			CalleeType *m_callee;
			FuncPtr m_function;

			void Clone(DelegatePointer &ptr) const
			{
				ptr.CopyConstruct(*this);
			}

			ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS)
			{
				return (m_callee->*m_function)(DELEGATE_DECLARE_FUNC_VALUES);
			}
		};
#pragma region(Assignment helper)
		template <typename CalleeType> static Callee<CalleeType> QCallee(CalleeType &callee, ReturnType (CalleeType::*func)(DELEGATE_DECLARE_FUNC_PARAMS))	{ return Callee<CalleeType>(callee, func); }
		template <typename CalleeType> static Callee<CalleeType> QCallee(CalleeType *callee, ReturnType (CalleeType::*func)(DELEGATE_DECLARE_FUNC_PARAMS))	{ return Callee<CalleeType>(callee, func); }
#pragma endregion
#pragma endregion

#pragma region(CopyCallee function delegate)
		template<typename CalleeType>
		class CopyCallee : public BaseDelegate
		{
		public:
			typedef ReturnType (CalleeType::*FuncPtr)(DELEGATE_DECLARE_FUNC_PARAMS);

			CopyCallee(CalleeType *callee, FuncPtr function)
				: m_callee(*callee), m_function(function)
			{
			}
			CopyCallee(CalleeType &callee, FuncPtr function)
				: m_callee(callee), m_function(function)
			{
			}

		private:
			CalleeType m_callee;
			FuncPtr m_function;

			void Clone(DelegatePointer &ptr) const
			{
				ptr.CopyConstruct(*this);
			}

			ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS)
			{
				return (m_callee.*m_function)(DELEGATE_DECLARE_FUNC_VALUES);
			}
		};
#pragma region(Assignment helper)
		template <typename CalleeType> static CopyCallee<CalleeType> QCopyCallee(CalleeType &callee, ReturnType (CalleeType::*func)(DELEGATE_DECLARE_FUNC_PARAMS))	{ return CopyCallee<CalleeType>(callee, func); }
		template <typename CalleeType> static CopyCallee<CalleeType> QCopyCallee(CalleeType *callee, ReturnType (CalleeType::*func)(DELEGATE_DECLARE_FUNC_PARAMS))	{ return CopyCallee<CalleeType>(callee, func); }
#pragma endregion
#pragma endregion
	};

}
#undef DELEGATE_DECLARE_NAME
#undef DELEGATE_DECLARE_FUNC_PARAMS
#undef DELEGATE_DECLARE_FUNC_VALUES
#undef DELEGATE_PARAM_COUNT

DataSourceManager.inl:

template <typename T>
void DataSourceManager::RegisterDataSource()
{
	DataSourcePtr dataSource = new T();
	Mortar::AsciiString name = dataSource->GetName();
	DataSourceMap::const_iterator it = m_dataSources.find(name);

	if (it == m_dataSources.end())
	{
		m_dataSources[name].SetPtr(dataSource);
	}
	else
	{
		ASSERT_MSG(false, "There is already a datasource in the manager with name '%s'", name.c_str());
	}
}

template <typename T>
DataSourcePtr DataSourceManager::GetDataSourceProxy()
{
	return GetDataSourceProxy(T::DataSourceName);
}

struct FindBinderByTypeId
{
	FindBinderByTypeId(u32 id)
		: m_id(id) {}
	bool operator()(const ComponentBinderPtr& binder)
	{
		ASSERT(binder != NULL);
		return binder.GetPtr()->GetComponentType() == m_id;
	}
	u32 m_id;
};

template <typename T>
void DataSourceManager::RegisterComponentDataBinder()
{
	ComponentBinderPtr binder;
	binder.SetPtr(new T());

	if (std::find_if(m_dataBinders.begin(), m_dataBinders.end(), FindBinderByTypeId(binder->GetComponentType())) == m_dataBinders.end())
	{
		m_dataBinders.push_back(binder);
	}
}

EffectManager.inl:

template <class T>
void EffectManager::AddEffectBuilder()
{
	Effect::BuilderBase *builder = new T();

	// we make sure this builder doesn't already exist!
	Mortar::AsciiString builderName = builder->GetName();
	EffectBuilderMap::iterator i = m_effectBuilderMap.find(builderName);
	if (i == m_effectBuilderMap.end())
	{
		m_effectBuilderMap[builderName] = builder;
	}
	else
	{
		delete builder;
	}
}

Delegates.inl:

// ------------------------------------------------------------------------------------------------
//
//  File: Delegates.inl
//
//      Description		- Implements the Delegate##DELEGATE_PARAM_COUNT class which allow for generic and
//						  flexible function pointers, if you need to add more parameters, please
//						  add them via the #define/#include method used in "Delegates.h"
//
//      Author			- Grant Peters
//
//  Modifications:
//  --------------
//      Sept 8, 2009	- Grant: Copied from my private engine.
//
// ------------------------------------------------------------------------------------------------

#define DELEGATE_DECLARE_NAME			PP_CONCAT(Delegate, DELEGATE_PARAM_COUNT)
#define DELEGATE_DECLARE_FUNC_PARAMS	PP_REPEAT_TEMPLATE_PARAM(DELEGATE_PARAM_COUNT)
#define DELEGATE_DECLARE_FUNC_VALUES	PP_REPEAT_TEMPLATE_VALUE(DELEGATE_PARAM_COUNT)
#define DELEGATE_DECLARE_FUNC_TYPES		PP_REPEAT_TEMPLATE_TYPE(DELEGATE_PARAM_COUNT)


namespace Mortar
{
	template<class ReturnType PP_COMMA_IF(DELEGATE_PARAM_COUNT) PP_REPEAT_TEMPLATE_DECL(DELEGATE_PARAM_COUNT)>
	class DELEGATE_DECLARE_NAME
	{
		struct BaseDelegate;
		typedef StackAllocatedPointer<BaseDelegate, 32> DelegatePointer;

		struct BaseDelegate
		{
			friend class DELEGATE_DECLARE_NAME/*<ReturnType PP_COMMA_IF(DELEGATE_PARAM_COUNT)  DELEGATE_DECLARE_FUNC_TYPES>*/;
			friend class StackAllocatedPointer<BaseDelegate, 32>;
			virtual ~BaseDelegate() {}

		private:
			virtual void Clone(DelegatePointer &ptr) const = 0;
			virtual ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS) = 0;
		};

		DelegatePointer m_delegate;
	public:

		DELEGATE_DECLARE_NAME() {}

		ReturnType operator() (DELEGATE_DECLARE_FUNC_PARAMS) const { return Call(DELEGATE_DECLARE_FUNC_VALUES);	}

		ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS) const
		{
			BaseDelegate *func = m_delegate.Resolve();
			if(func != NULL)
				return func->Call(DELEGATE_DECLARE_FUNC_VALUES);

			// If the program fails to compile at this line, use 'CallNoNullCheck()' instead
			// you should also wrap the code in 'if(Delegate.IsNull())' when doing this so as
			// to handle NULL pointers and AVOID A CRASH!!!
			return ReturnType();	
		}

		// You should also wrap the code in 'if(Delegate.IsNull())' when using this function
		// so as to handle NULL pointers and AVOID A CRASH!!!
		ReturnType CallNoNullCheck (DELEGATE_DECLARE_FUNC_PARAMS) const
		{
			BaseDelegate *func = m_delegate.Resolve();
			ASSERT_MSG(func != NULL, "'Delegate.CallNoNullCheck()' called when the delegate was NULL,\nplease wrap code in an 'if(Delegate.IsNull())' to protect against this scenario!");
			return func->Call(DELEGATE_DECLARE_FUNC_VALUES);
		}

		bool IsNull()
		{
			return m_delegate.Resolve() == NULL;
		}

#pragma region(BaseDelegate assignments)
		void operator=(const BaseDelegate &func)
		{
			func.Clone(m_delegate);
		}
		DELEGATE_DECLARE_NAME(const BaseDelegate &func)
		{
			func.Clone(m_delegate);
		}
#pragma endregion

#pragma region(Static/Global function delegate)
		class Global : public BaseDelegate
		{
		public:
			typedef ReturnType (*FuncPtr)(DELEGATE_DECLARE_FUNC_PARAMS);
			Global(FuncPtr function)
				: m_function(function)
			{
			}

			Global(const Global &copy)
				: m_function(copy.m_function)
			{
			}

		private:
			FuncPtr m_function;

			void Clone(DelegatePointer &ptr) const
			{
				ptr.CopyConstruct(*this);
			}

			ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS)
			{
				return m_function(DELEGATE_DECLARE_FUNC_VALUES);
			}
		};
#pragma region(Assignment helper)
		DELEGATE_DECLARE_NAME(typename Global::FuncPtr globalFunc)
		{
			if(globalFunc != NULL)
				*this = Global(globalFunc);
			else
				m_delegate.Delete();
		}
		void operator=(typename Global::FuncPtr globalFunc)
		{
			if(globalFunc != NULL)
				*this = Global(globalFunc);
			else
				m_delegate.Delete();
		}
#pragma endregion
#pragma endregion

#pragma region(Callee function delegate)
		template<typename CalleeType>
		class Callee : public BaseDelegate
		{
		public:
			typedef ReturnType (CalleeType::*FuncPtr)(DELEGATE_DECLARE_FUNC_PARAMS);

			Callee(CalleeType *callee, FuncPtr function)
				: m_callee(callee), m_function(function)
			{
			}
			Callee(CalleeType &callee, FuncPtr function)
				: m_callee(&callee), m_function(function)
			{
			}

		private:
			CalleeType *m_callee;
			FuncPtr m_function;

			void Clone(DelegatePointer &ptr) const
			{
				ptr.CopyConstruct(*this);
			}

			ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS)
			{
				return (m_callee->*m_function)(DELEGATE_DECLARE_FUNC_VALUES);
			}
		};
#pragma region(Assignment helper)
		template <typename CalleeType> static Callee<CalleeType> QCallee(CalleeType &callee, ReturnType (CalleeType::*func)(DELEGATE_DECLARE_FUNC_PARAMS))	{ return Callee<CalleeType>(callee, func); }
		template <typename CalleeType> static Callee<CalleeType> QCallee(CalleeType *callee, ReturnType (CalleeType::*func)(DELEGATE_DECLARE_FUNC_PARAMS))	{ return Callee<CalleeType>(callee, func); }
#pragma endregion
#pragma endregion

#pragma region(CopyCallee function delegate)
		template<typename CalleeType>
		class CopyCallee : public BaseDelegate
		{
		public:
			typedef ReturnType (CalleeType::*FuncPtr)(DELEGATE_DECLARE_FUNC_PARAMS);

			CopyCallee(CalleeType *callee, FuncPtr function)
				: m_callee(*callee), m_function(function)
			{
			}
			CopyCallee(CalleeType &callee, FuncPtr function)
				: m_callee(callee), m_function(function)
			{
			}

		private:
			CalleeType m_callee;
			FuncPtr m_function;

			void Clone(DelegatePointer &ptr) const
			{
				ptr.CopyConstruct(*this);
			}

			ReturnType Call(DELEGATE_DECLARE_FUNC_PARAMS)
			{
				return (m_callee.*m_function)(DELEGATE_DECLARE_FUNC_VALUES);
			}
		};
#pragma region(Assignment helper)
		template <typename CalleeType> static CopyCallee<CalleeType> QCopyCallee(CalleeType &callee, ReturnType (CalleeType::*func)(DELEGATE_DECLARE_FUNC_PARAMS))	{ return CopyCallee<CalleeType>(callee, func); }
		template <typename CalleeType> static CopyCallee<CalleeType> QCopyCallee(CalleeType *callee, ReturnType (CalleeType::*func)(DELEGATE_DECLARE_FUNC_PARAMS))	{ return CopyCallee<CalleeType>(callee, func); }
#pragma endregion
#pragma endregion
	};

}
#undef DELEGATE_DECLARE_NAME
#undef DELEGATE_DECLARE_FUNC_PARAMS
#undef DELEGATE_DECLARE_FUNC_VALUES
#undef DELEGATE_PARAM_COUNT

DeviceResource.inl:

// ------------------------------------------------------------------------------------------------
//
//  File: DeviceResource.inl
//
//      Description		- Implements the static functions that enumerate through all resources
//						  informing them of a specific event.
//      Author			- Grant Peters
//
//  Modifications:
//  --------------
//      Sept 8, 2009	- Grant: Copied from my private engine.
//
// ------------------------------------------------------------------------------------------------

namespace Mortar
{
	template<typename DeviceType>
	void DeviceResource<DeviceType>::TriggerDeviceLost(DeviceType *device)
	{
		for(DeviceResource *resource = HeadInstance(); resource != NULL; resource = resource->NextInstance())
		{
			resource->DeviceLost(device);
		}
	}

	template<typename DeviceType>
	void DeviceResource<DeviceType>::TriggerDeviceReset(DeviceType *device)
	{
		for(DeviceResource *resource = HeadInstance(); resource != NULL; resource = resource->NextInstance())
		{
			resource->DeviceReset(device);
		}
	}
}

Effect.inl:

// template implementation
template <class T>
T Effect::Animation::Interpolate(const Mortar::AsciiString &interpolationType, T v1, T v2, float time)
{
	static float s_pi = 3.141592f;
	static float s_piOn2 = s_pi * 0.5f;

	if (interpolationType.EqualsI("sin") == true)
	{
		T diff = v2 - v1;
		time *= s_piOn2;
		
		return v1 + (diff * sinf(time));
	}
	else if (interpolationType.EqualsI("cos") == true)
	{
		T diff = v2 - v1;
		time *= s_piOn2;
		
		return v1 + (diff * (1.0f - cosf(time)));
	}
	
	// default to linear
	return v1 + ((v2 - v1) * time);
}


template <class T>
void Effect::SetVariableFromParam(T &var, const Mortar::AsciiString &paramKey, ParamMap &params)
{
	ParamMap::iterator param = params.find(paramKey);
	if (param != params.end())
	{
		SetVariableFromString(var, param->second);
	}
}

template <class T>
bool Effect::SetVariableIfDefault(T &var, const Mortar::AsciiString &valueString, T def)
{
	if (valueString.Equals("*") == true)
	{
		var = def;
		return true;
	}

	return false;
}

List.inl

// ------------------------------------------------------------------------------------------------
//
//  List.inl
//
// ------------------------------------------------------------------------------------------------

#include "../Startup/Macros.h"
#include "../Memory/MortarMemory.h"

template<typename T>
FreeList* List<T>::CreateNewMemoryAlloc(StackHeap *heap, u32 size)
{
	FreeList *free_list = new FreeList(heap, size);
	return free_list;
}

template<typename T>
void* List<T>::AllocMemory(FreeList *free_list)
{
	return free_list->Allocate();
}

template<typename T>
void List<T>::ReleaseMemory(FreeList *free_list, void *p)
{
	free_list->Release(p);
}

// Constructor
//
template<typename T>
List<T>::List()
{
	count  = 0;        
	head   = 0;
	tail   = 0;
	method = METHOD_NONE;
	private_mem_alloc = 0;

	memory_allocator = NULL;
}

template<typename T>
List<T>::List(StackHeap *heap)
{
	count  = 0;        
	head   = 0;
	tail   = 0;
	method = METHOD_NONE;
	private_mem_alloc = 1;

	if(heap)
		memory_allocator = CreateNewMemoryAlloc(heap, sizeof(List<T>::Node));
	else
		memory_allocator = NULL;
}

template<typename T>
List<T>::List(FreeList *list)
{
	count  = 0;        
	head   = 0;
	tail   = 0;
	method = METHOD_NONE;
	private_mem_alloc = 0;

	memory_allocator = list;
}

template<typename T>
void List<T>::Init()
{
	count  = 0;        
	head   = 0;
	tail   = 0;
	method = METHOD_NONE;
	private_mem_alloc = 0;

	memory_allocator = NULL;
}

template<typename T>
void List<T>::Init(StackHeap *heap)
{
	count  = 0;        
	head   = 0;
	tail   = 0;
	method = METHOD_NONE;
	private_mem_alloc = 1;

	if(heap)
		memory_allocator = CreateNewMemoryAlloc(heap, sizeof(List<T>::Node));
	else
		memory_allocator = NULL;
}

template<typename T>
void List<T>::Init(FreeList *list)
{
	count  = 0;        
	head   = 0;
	tail   = 0;
	method = METHOD_NONE;
	private_mem_alloc = 0;

	memory_allocator = list;
}

// Destructor
//
template<typename T>
List<T>::~List()
{
	Destroy();
}


// Destroy
//
template<typename T>
void List<T>::Destroy()
{
	Clear();
	if(private_mem_alloc)
		SAFE_DELETE(memory_allocator);
}

// Method: Clear
//
//      The list is completely cleared by this call and is then free to be reused with either method.
//
template<typename T>
void List<T>::Clear()
{
	// Only delete nodes if we created them.
	if (method == METHOD_CREATE)
	{
		Node* curr = head;
		Node* next;

		if(!memory_allocator)
		{
			while (curr)
			{
				next = curr->next;

				delete curr;
				

				curr = next;
			}
		}
		else
		{
			
			while (curr)
			{
				next = curr->next;

				ReleaseMemory(memory_allocator, curr);				

				curr = next;
			}
			
		}

	}

	count  = 0;        
	head   = 0;
	tail   = 0;
	method = METHOD_NONE;
//	if(memory_allocator)
}


template<typename T>
void List<T>::ClearFreeList()
{
	ASSERT(private_mem_alloc);
	if(memory_allocator)memory_allocator->Clear();
}




// Adds a node at the head of the linked list.
//
template<typename T>
void List<T>::AddHead(Node* node)
{
	ASSERT(node);        

	if (method == METHOD_NONE)
		method =  METHOD_ADD;

	ASSERT(method == METHOD_ADD);

	AddNodeToHead(node);
}



// Adds a node at the tail of the linked list.
//
template<typename T>
void List<T>::AddTail(Node* node)
{
	ASSERT(node);        

	if (method == METHOD_NONE)
		method =  METHOD_ADD;

	ASSERT(method == METHOD_ADD);
	
	AddNodeToTail(node);
}



// Method: AddHead
//
//      Adds an item at the head of the linked list.
//
template<typename T>
void List<T>::AddHead(T item)
{
	if (method == METHOD_NONE)
		method =  METHOD_CREATE;

	ASSERT(method == METHOD_CREATE);
	
	Node* node = NULL;
	if(!memory_allocator)
	{
		node = new Node(item);
	}
	else
	{
		node = (Node*)AllocMemory(memory_allocator);
	}
	ASSERT(node);
	
	node->item = item;
	node->prev = 0;
	node->next = 0;

	
	
	AddNodeToHead(node);
}



// Method: AddTail
//
//      Adds a node at the tail of the linked list.
//
template<typename T>
void List<T>::AddTail(T item)
{
	if (method == METHOD_NONE)
		method =  METHOD_CREATE;

	ASSERT(method == METHOD_CREATE);
	
	Node* node = NULL;
	if(!memory_allocator)
	{
		node = new Node(item);
	}
	else
	{
		node = (Node*)AllocMemory(memory_allocator);
	}
	
	ASSERT(node);

	node->item = item;
	node->prev = 0;
	node->next = 0;

	 
	
	AddNodeToTail(node); 
}



// Finds an items node if it is held within the list.
//
template<typename T>
void List<T>::Remove(const T item)
{
	Node* node = Find(item);

	if ( node)
	{
        Remove(node);
	}
}



// Finds an items node if it is held within the list.
//
template<typename T>
void List<T>::Remove(Node* node)
{
	if (node)
	{
		// Keep a pointer to the current node, so we can delete it.
		Node* temp = node;


		// Remove the head node?
		if (node == head)
		{
			// Are there any nodes left?
			if (head->next)
			{
				// Remove old head node.
				head  = head->next;
				
				head->prev = 0;
			}
			else
			{
				head = 0;
				tail = 0;
			}
		}

		// Remove the tail node?
		else if (node == tail)
		{
			// Are there any nodes left?
			if (tail->prev)
			{
				// Remove old tail node.
				tail = tail->prev;
				
				tail->next = 0;

			}
			else
			{
				head = 0;
				tail = 0;
			}
		}

		// Remove inbetween node.
		else
		{
			node->prev->next = node->next;
			node->next->prev = node->prev;
		}

	
		// Now we can call delete on the node that has been unlinked.
		if (method == METHOD_CREATE)
		{   
			if(!memory_allocator)
			{
				delete temp;
			}
			else
			{
				ReleaseMemory(memory_allocator, temp);
			}
		}
	
	
		// Reduce count.
		if (--count == 0)
		{
			method = METHOD_NONE;
		}
	}
}



// Inserts an item into the list.
//
template<typename T>
void List<T>::Insert(Node* curr, const T item, const InsertPos insert)
{
    if (method == METHOD_NONE)
		method =  METHOD_CREATE;

	ASSERT(method == METHOD_CREATE);

	Node* node = NULL;
	if(!memory_allocator)
	{
		node = new Node(item);
	}
	else
	{
		node = (Node*)AllocMemory(memory_allocator);
	}
	node->item = item;
	node->prev = 0;
	node->next = 0;

	ASSERT(node);
	ASSERT(curr);

    InsertNode(curr, node, insert);
}



// Inserts a node into the list.
//
template<typename T>
void List<T>::Insert(Node* curr, Node* node, const InsertPos insert)
{
	if (method == METHOD_NONE)
		method =  METHOD_ADD;

	ASSERT(method == METHOD_ADD);
	ASSERT(node);
	ASSERT(curr);

    InsertNode(curr, node, insert);
}


//      Inserts an item into the list.
//
template<typename T>
void List<T>::Insert(Iterator it, const T item, const InsertPos insert)
{
    if (method == METHOD_NONE)
		method =  METHOD_CREATE;

	ASSERT(method == METHOD_CREATE);

	Node* node = NULL;
	if(!memory_allocator)
	{
		node = new Node(item);
	}
	else
	{
		node = (Node*)AllocMemory(memory_allocator);
	}
	node->item = item;
	node->prev = 0;
	node->next = 0;

	ASSERT(node);
	ASSERT(it.curr);

    InsertNode(it.curr, node, insert);
}


//      Inserts a node into the list.
template<typename T>
void List<T>::Insert(Iterator it, Node* node, const InsertPos insert)
{
	if (method == METHOD_NONE)
		method =  METHOD_ADD;

	ASSERT(method == METHOD_ADD);
	ASSERT(node);
	ASSERT(it.curr);

    InsertNode(it.curr, node, insert);
}


// Removes an current item from the list.
template<typename T>
void List<T>::RemoveAt(int index)
{
    ASSERT(index < count);
    ASSERT(head);

    Node* node = head;
    int i = 0;
    while(node)
    {
        if (i++ == index)
        {
            Remove(node);
            return;
        }

        node = node->next;
    }
}


// Removes all the items at the specified indices
//
template<typename T>
void List<T>::RemoveRange(int start, int end)
{
    ASSERT(start < count);
    ASSERT(end   < count);
    ASSERT(start > -1);
    ASSERT(end   > -1);

    if (start > end)
    {
        SWAP(start, end);
    }

    int count = (end - start);

    for (int i=0; i<count; i++)
    {
        RemoveAt(start); // Removes same index *count* times as the links shift down
    }
}


// ------------------------------------------------------------------------------------------------
//
//  Private methods.
//
// ------------------------------------------------------------------------------------------------

// Adds a new node at the lists beginning.
//
template<typename T>
void List<T>::AddNodeToHead(Node* node)
{
	if (0 == head)
	{
		head = node;
		tail = node;

		node->prev = 0;
		node->next = 0;
	}
	else
	{
		node->prev = 0;         // As this is the new head node, there will be no previous.
		node->next = head;      // New head nodes next will be old head node.
		head->prev = node;      // Old head nodes previous must now point to the new head.
		head       = node;      // Set new head node.
	}

	count++;
}


// Adds a new node at the lists end.
//
template<typename T>
void List<T>::AddNodeToTail(Node* node)
{
	if (0 == tail)
	{
		head = node;
		tail = node;

		node->prev = 0;
		node->next = 0;
	}
	else
	{
		tail->next = node;      // Old tails next must be set to point at the new node.
		node->prev = tail;      // New nodes previous must be the current tail.
		node->next = 0;         // New nodes next is 0.
		tail       = node;      // Now set tail node to point to the new node.
	}

	count++;
}


// Inserts a node into the list.
//
template<typename T>
void List<T>::InsertNode(Node* curr, Node* node, const InsertPos insert)
{
    if (insert == AFTER)
    {
        node->next = curr->next;

        node->prev = curr;

        if (curr->next)
        {
            curr->next->prev = node;
        }

        curr->next = node;


        // Is inserted node the new tail?
        if (curr == tail)
        {
             tail = node;
        }
    }
    else
    {
        node->prev = curr->prev;

        node->next = curr;

        if (curr->prev)
        {
            curr->prev->next = node;
        }

        curr->prev = node;


        // Is inserted node the new head?
        if (curr == head)
        {
             head = node;
        }
    }

    count++;
}

Matrix.inl:

// ------------------------------------------------------------------------------------------------
//
// Matrix.inl
//
// ------------------------------------------------------------------------------------------------

template<class T>
const _Matrix44<T> _Matrix44<T>::Identity(
	1,0,0,0,
	0,1,0,0,
	0,0,1,0,
	0,0,0,1);



template<class T> void _Matrix33<T>::Copy33To43(_Matrix43<T> &dest) const
{
	for(int i =0;i<9;i++)
		dest.a[i]=a[i];
	dest._30 = 0;
	dest._31 = 0;
	dest._32 = 0;
}

template<class T> void _Matrix33<T>::Copy33To44(_Matrix44<T> &dest) const
{
	dest._00 = _00;
	dest._01 = _01;
	dest._02 = _02;
	dest._03 = 0;
	dest._10 = _10;
	dest._11 = _11;
	dest._12 = _12;
	dest._13 = 0;
	dest._20 = _20;
	dest._21 = _21;
	dest._22 = _22;
	dest._23 = 0;
	dest._30 = 0;
	dest._31 = 0;
	dest._32 = 0;
	dest._33 = 1.0f;
}

template<class T> void _Matrix43<T>::Copy43To33(_Matrix33<T> &dest) const
{
	for(int i =0;i<9;i++)
		dest.a[i]=a[i];
}

template<class T> void _Matrix43<T>::Copy43To44(_Matrix44<T> &dest) const
{
	dest._00 = _00;
	dest._01 = _01;
	dest._02 = _02;
	dest._03 = 0;
	dest._10 = _10;
	dest._11 = _11;
	dest._12 = _12;
	dest._13 = 0;
	dest._20 = _20;
	dest._21 = _21;
	dest._22 = _22;
	dest._23 = 0;
	dest._30 = _30;
	dest._31 = _31;
	dest._32 = _32;
	dest._33 = 1.0f;
}

template<class T> void _Matrix44<T>::Copy44To33(_Matrix33<T> &dest) const
{
	dest._00 = _00;
	dest._01 = _01;
	dest._02 = _02;
	dest._10 = _10;
	dest._11 = _11;
	dest._12 = _12;
	dest._20 = _20;
	dest._21 = _21;
	dest._22 = _22;
}

template<class T> void _Matrix44<T>::Copy44To43(_Matrix43<T> &dest) const
{
	dest._00 = _00;
	dest._01 = _01;
	dest._02 = _02;
	dest._10 = _10;
	dest._11 = _11;
	dest._12 = _12;
	dest._20 = _20;
	dest._21 = _21;
	dest._22 = _22;
	dest._30 = _30;
	dest._31 = _31;
	dest._32 = _32;
}

MatrixStack.inl:

// ------------------------------------------------------------------------------------------------
//
//  File: MatrixStack.inl
//
//      Description     - Implementation of the inline MatrixStack functions
//      Author          - Aidan Millott
//
//  Modifications:
//  --------------
//      August 4, 2009   - Initial creation.
//
// ------------------------------------------------------------------------------------------------


// Push the current Matrix onto the stack
inline void MatrixStack::Push()
{
	ASSERT(m_currentStackIndex < MAX_STACK_SIZE);

	m_currentStackIndex++;

	m_mtxStack[m_currentStackIndex] = m_currentMtx;
}

// Pop the required amount of matricies off the stack
inline void MatrixStack::Pop(u8 num)
{
	ASSERT(m_currentStackIndex >= num);

	m_currentStackIndex = (u8)(m_currentStackIndex - num);

	m_currentMtx = m_mtxStack[m_currentStackIndex];
}

// copy the current matrix to the desired area of the stack
inline void MatrixStack::Store(u8 num)
{
	ASSERT(num < MAX_STACK_SIZE);

	m_mtxStack[num] = m_currentMtx;
}

// restores a previously stored Matrix
inline void MatrixStack::Restore(u8 num)
{
	ASSERT(num < MAX_STACK_SIZE);

	m_currentMtx = m_mtxStack[num];
}

// reset the matrix stack to the default values
inline void MatrixStack::Reset()
{
	m_currentStackIndex = 0;
	m_mtxStack[m_currentStackIndex] = Mtx44::Identity;
	m_currentMtx = Mtx44::Identity;
}

inline void MatrixStack::Translate(Vector3 amount)
{
	m_currentMtx.GlobalTranslate44(amount.x, amount.y, amount.z);
}

inline void MatrixStack::Translate2D(Vector2 amount)
{
	//m_currentMtx._20 = amount.x * m_currentMtx._00 + amount.y * m_currentMtx._10;
	//m_currentMtx._21 = amount.x * m_currentMtx._01 + amount.y * m_currentMtx._11;
	m_currentMtx._20 += amount.x;
	m_currentMtx._21 += amount.y;
}

inline void MatrixStack::TranslateLocal(Vector3 amount)
{
	m_currentMtx.LocalTranslate44(amount.x, amount.y, amount.z);
}

inline void MatrixStack::Scale(Vector3 amount)
{
	m_currentMtx.Scale44(amount.x, amount.y, amount.z);
}

inline void MatrixStack::RotX(dec32 amount)
{
	m_currentMtx.RotX44(Math::SinIdx(DEGREE_TO_IDX(amount)),Math::CosIdx(DEGREE_TO_IDX(amount)));
}

inline void MatrixStack::RotY(dec32 amount)
{
	m_currentMtx.RotY44(Math::SinIdx(DEGREE_TO_IDX(amount)),Math::CosIdx(DEGREE_TO_IDX(amount)));
}

inline void MatrixStack::RotZ(dec32 amount)
{
	m_currentMtx.RotZ44(Math::SinIdx(DEGREE_TO_IDX(amount)),Math::CosIdx(DEGREE_TO_IDX(amount)));
}

inline void MatrixStack::MtxMul(Mtx44 mul)
{
	m_currentMtx.Mul44(mul);
}

Vector2.inl:

// ------------------------------------------------------------------------------------------------
//
//  File: Vector2.inl
//
//      Description     - Implementation of the inline Vector2 functions
//      Author          - Aidan Millott
//
//  Modifications:
//  --------------
//      July 29, 2009   - Initial creation.
//		July 30, 2009	- Woody Updated to templates
//		July 30, 2009	- Paul McNab converted for 2D use.
//
// ------------------------------------------------------------------------------------------------


// Operator +
//
template <class T> const _Vector2<T> _Vector2<T>::One  = _Vector2<T>(1.0f, 1.0f);
template <class T> const _Vector2<T> _Vector2<T>::Zero = _Vector2<T>(0.0f, 0.0f); 
template <class T> const _Vector2<T> _Vector2<T>::UnitY = _Vector2<T>(0.0f, 1.0f); 
template <class T> const _Vector2<T> _Vector2<T>::UnitX = _Vector2<T>(1.0f, 0.0f); 



template <class T> _Vector2<T> _Vector2<T>::operator + ( const _Vector2<T>& rhs ) const
{
	return _Vector2<T>( x + rhs.x, y + rhs.y );
}

template <class T> _Vector2<T> _Vector2<T>::operator + ( T rhs ) const
{
	return _Vector2<T>( x + rhs, y + rhs );
}


// Operator -
//
template <class T> _Vector2<T> _Vector2<T>::operator - ( const _Vector2<T>& rhs ) const
{
	return _Vector2<T>( x - rhs.x, y - rhs.y );
}

template <class T> _Vector2<T> _Vector2<T>::operator - ( T rhs ) const
{
	return _Vector2<T>( x - rhs, y - rhs );
}


// Operator *
//
template <class T> _Vector2<T> _Vector2<T>::operator * ( const T& rhs ) const
{
	return	_Vector2<T>
		(
		x * rhs,
		y * rhs
		);
}

template <class T> _Vector2<T> _Vector2<T>::operator * (const _Vector2<T>& val) const
{
	return _Vector2<T>
		(
		x * val.x,
		y * val.y
		);
}


// Operator >>/<<
//
template <class T> _Vector2<T> _Vector2<T>::operator >> ( const u32 val ) const
{
	return	_Vector2<T>
		(
		x>>val,
		y>>val
		);
}


template <class T> _Vector2<T> _Vector2<T>::operator << ( const u32 val ) const
{
	return	_Vector2<T>
		(
		x<<val,
		y<<val
		);
}


// Operator /
//
template <class T> _Vector2<T> _Vector2<T>::operator / ( const T& rhs ) const
{
	return	_Vector2<T>
		(
		x / rhs,
		y / rhs
		);
}



// Operator +=
//
template <class T> _Vector2<T>& _Vector2<T>::operator += (const _Vector2<T>& rhs )
{
	x += rhs.x;
	y += rhs.y;

	return *this;
}


// Operator >>=/<<=
//
template <class T> _Vector2<T>& _Vector2<T>::operator >>= (const u32 val )
{
	x >>= val;
	y >>= val;

	return *this;
}

template <class T> _Vector2<T>& _Vector2<T>::operator <<= (const u32 val )
{
	x <<= val;
	y <<= val;

	return *this;
}


// Operator -=
//
template <class T> _Vector2<T>& _Vector2<T>::operator -= ( const _Vector2<T>& rhs )
{
	x -= rhs.x;
	y -= rhs.y;

	return *this;
}


// Operator *=
//
template <class T> _Vector2<T>& _Vector2<T>::operator *= ( const T val )
{
	x *= val;
	y *= val;

	return *this;
}

template <class T> _Vector2<T> _Vector2<T>::operator *= (const _Vector2<T>& val)
{
	x *= val.x;
	y *= val.y;

	return *this;
}


// Operator /=
//
template <class T> _Vector2<T>& _Vector2<T>::operator /= ( const T val )
{
	x /= val;
	y /= val;

	return *this;
}


// Operator -
//
template <class T> _Vector2<T> _Vector2<T>::operator - () const
{
	return _Vector2<T>(-x, -y);
}


// Operator ==
//
template <class T> bool _Vector2<T>::operator == (const _Vector2<T> &v) const
{
	return (x == v.x && y == v.y);
}


// Operator !=
//
template <class T> bool _Vector2<T>::operator != (const _Vector2<T> &v) const
{
	return (x != v.x || y != v.y );
}

template <class T> bool _Vector2<T>::Equals(const _Vector2 &v, float tolerance) const
{
	return
		BETWEEN(x-v.x, -tolerance, tolerance) &&
		BETWEEN(y-v.y, -tolerance, tolerance);
}


// Magnitude
//
template <class T> T _Vector2<T>::Magnitude() const
{
	return Math::Sqrt(MagnitudeSqr());
}


// MagnitudeSqr
//
template <class T> T _Vector2<T>::MagnitudeSqr() const
{
	return Dot(*this);
}


// Normalise
//
template <class T> float _Vector2<T>::Normalise()
{
	if(x == 0 && y == 0)
		return 0;

	T denom = Magnitude();
	if(denom != 0)
	{
		*this /= denom;
	}
	else
	{
		//wasn't 0, but was very small, multiply by a large number
		*this *= 1000000;
		Normalise();
	}

	return denom;
}


// Cross
//
/*
template <class T> T _Vector2<T>::Cross(const _Vector2<T>& rhs) const
{
	_Vector2<T> res;

	res.x = (y * rhs.z) - (rhs.y * z);
	res.y = (z * rhs.x) - (rhs.z * x);

	return res;
}
*/


// Dot
//
template <class T> T _Vector2<T>::Dot(const _Vector2<T>& rhs) const
{
	return (x * rhs.x) + (y * rhs.y);
}


// Lerp
//
template <class T> _Vector2<T> _Vector2<T>::Lerp(const _Vector2<T>& rhs, const T time) const
{
	_Vector2<T> tmp = (rhs - *this) * time;
	return *this + tmp;
}


// Magnitude
//
template <class T> T _Vector2<T>::Magnitude(_Vector2<T> v)
{
	return v.Magnitude();
}


// MagnitudeSqr
//
template <class T> T _Vector2<T>::MagnitudeSqr(_Vector2<T> v)
{
	return v.MagnitudeSqr();
}


// Normalise
//
template <class T> _Vector2<T> _Vector2<T>::Normalise(_Vector2<T> v)
{
	v.Normalise();
	return v;
}


// Cross
//
template <class T> _Vector2<T> _Vector2<T>::Cross(_Vector2<T> lhs, _Vector2<T> rhs)
{
	return lhs.Cross(rhs);
}


// Dot
//
template <class T> T _Vector2<T>::Dot(_Vector2<T> lhs, _Vector2<T> rhs)
{
	return lhs.Dot(rhs);
}


// Lerp
//
template <class T> _Vector2<T> _Vector2<T>::Lerp(_Vector2<T> lhs, _Vector2<T> rhs, T time)
{
	return lhs.Lerp(rhs, time);
}


template <class T> inline _Vector2<T> operator + ( const T& lhs, const _Vector2<T>& rhs) { return _Vector2<T>(lhs + rhs.x, lhs + rhs.y); }
template <class T> inline _Vector2<T> operator - ( const T& lhs, const _Vector2<T>& rhs) { return _Vector2<T>(lhs - rhs.x, lhs - rhs.y); }
template <class T> inline _Vector2<T> operator * ( const T& lhs, const _Vector2<T>& rhs) { return _Vector2<T>(lhs * rhs.x, lhs * rhs.y); }
template <class T> inline _Vector2<T> operator / ( const T& lhs, const _Vector2<T>& rhs) { return _Vector2<T>(lhs / rhs.x, lhs / rhs.y); }

// Returns the points data as a string.
//
template <class T> const char *_Vector2<T>::ToString() const
{
	static char buffer[256];
#if defined(PLATFORM_PC) || defined(PLATFORM_360)
	sprintf_s(buffer, "%i, %i", (s32)x, (s32)y);
#else
	sprintf(buffer, "%i, %i", (s32)x, (s32)y);
#endif
	return buffer;
}

Vector3.inl:

// ------------------------------------------------------------------------------------------------
//
//  File: Vector3.inl
//
//      Description     - Implementation of the inline Vector3 functions
//      Author          - Aidan Millott
//
//  Modifications:
//  --------------
//      July 29, 2009   - Initial creation.
//		July 30, 2009	- Woody Updated to templates
//
// ------------------------------------------------------------------------------------------------

// Operator +
//

template <class T> const _Vector3<T> _Vector3<T>::One = _Vector3<T>(1.0f,1.0f,1.0f);
template <class T> const _Vector3<T> _Vector3<T>::Zero = _Vector3<T>(0.0f,0.0f,0.0f); 
template <class T> const _Vector3<T> _Vector3<T>::UnitX = _Vector3<T>(1.0f,0.0f,0.0f); 
template <class T> const _Vector3<T> _Vector3<T>::UnitY = _Vector3<T>(0.0f,1.0f,0.0f); 
template <class T> const _Vector3<T> _Vector3<T>::UnitZ = _Vector3<T>(0.0f,0.0f,1.0f); 


template <class T> _Vector3<T> _Vector3<T>::operator + ( const _Vector3<T>& rhs ) const
{
	return _Vector3<T>( x + rhs.x, y + rhs.y, z + rhs.z );
}

template <class T> _Vector3<T> _Vector3<T>::operator + ( T rhs ) const
{
	return _Vector3<T>( x + rhs, y + rhs, z + rhs );
}



// Operator -
//
template <class T> _Vector3<T> _Vector3<T>::operator - ( const _Vector3<T>& rhs ) const
{
	return _Vector3<T>( x - rhs.x, y - rhs.y, z - rhs.z );
}

template <class T> _Vector3<T> _Vector3<T>::operator - ( T rhs ) const
{
	return _Vector3<T>( x - rhs, y - rhs, z - rhs );
}



// Operator *
//
template <class T> _Vector3<T> _Vector3<T>::operator * ( const T& rhs ) const
{
	return	_Vector3<T>
		(
		x * rhs,
		y * rhs,
		z * rhs
		);
}

template <class T> _Vector3<T> _Vector3<T>::operator * (const _Vector3<T>& val) const
{
	return _Vector3<T>
		(
		x * val.x,
		y * val.y,
		z * val.z
		);
}

// Operator >>/<<
template <class T> _Vector3<T> _Vector3<T>::operator >> ( const u32 val ) const
{
	return	_Vector3<T>
		(
		x>>val,
		y>>val,
		z>>val
		);
}


template <class T> _Vector3<T> _Vector3<T>::operator << ( const u32 val ) const
{
	return	_Vector3<T>
		(
		x<<val,
		y<<val,
		z<<val
		);
}

// Operator /
//

template <class T> _Vector3<T> _Vector3<T>::operator / ( const T& rhs ) const
{
	return	_Vector3<T>
		(
		x / rhs,
		y / rhs,
		z / rhs
		);
}



// Operator +=
//
template <class T> _Vector3<T>& _Vector3<T>::operator += (const _Vector3<T>& rhs )
{
	x += rhs.x;
	y += rhs.y;
	z += rhs.z;

	return *this;
}

// Operator >>=/<<=

template <class T> _Vector3<T>& _Vector3<T>::operator >>= (const u32 val )
{
	x >>= val;
	y >>= val;
	z >>= val;

	return *this;
}

template <class T> _Vector3<T>& _Vector3<T>::operator <<= (const u32 val )
{
	x <<= val;
	y <<= val;
	z <<= val;

	return *this;
}



// Operator -=
//
template <class T> _Vector3<T>& _Vector3<T>::operator -= ( const _Vector3<T>& rhs )
{
	x -= rhs.x;
	y -= rhs.y;
	z -= rhs.z;

	return *this;
}



// Operator *=
//
template <class T> _Vector3<T>& _Vector3<T>::operator *= ( const T val )
{
	x *= val;
	y *= val;
	z *= val;

	return *this;
}

template <class T> _Vector3<T> _Vector3<T>::operator *= (const _Vector3<T>& val)
{
	x *= val.x;
	y *= val.y;
	z *= val.z;

	return *this;
}


// Operator /=
template <class T> _Vector3<T>& _Vector3<T>::operator /= ( const T val )
{
	x /= val;
	y /= val;
	z /= val;

	return *this;
}



// Operator -
//
template <class T> _Vector3<T> _Vector3<T>::operator - () const
{
	return _Vector3<T>(-x, -y, -z);
}



// Operator ==
template <class T> bool _Vector3<T>::operator == (const _Vector3<T> &v) const
{
	return (x == v.x && y == v.y && z == v.z);
}


// Operator !=
template <class T> bool _Vector3<T>::operator != (const _Vector3<T> &v) const
{
	return (x != v.x || y != v.y || z != v.z);
}

template <class T> bool _Vector3<T>::Equals(const _Vector3 &v, float tolerance) const
{
	return
		BETWEEN(x-v.x, -tolerance, tolerance) &&
		BETWEEN(y-v.y, -tolerance, tolerance) &&
		BETWEEN(z-v.z, -tolerance, tolerance) ;
}

// Magnitude
//
template <class T> T _Vector3<T>::Magnitude() const
{
	return Math::Sqrt(MagnitudeSqr());
}



// MagnitudeSqr
//
template <class T> T _Vector3<T>::MagnitudeSqr() const
{
	return Dot(*this);
}



// Normalise
//
template <class T> float _Vector3<T>::Normalise()
{
	if(x == 0 && y == 0 && z == 0)
		return 0;

	T denom = Magnitude();
	if(denom != 0)
	{
		*this /= denom;
	}
	else
	{
		//wasn't 0, but was very small, multiply by a large number
		*this *= 1000000;
		Normalise();
	}

	return denom;
}



// Cross
//
template <class T> _Vector3<T> _Vector3<T>::Cross(const _Vector3<T>& rhs) const
{
	_Vector3<T> res;

	res.x = (y * rhs.z) - (rhs.y * z);
	res.y = (z * rhs.x) - (rhs.z * x);
	res.z = (x * rhs.y) - (rhs.x * y);

	return res;
}



// Dot
//
template <class T> T _Vector3<T>::Dot(const _Vector3<T>& rhs) const
{
	return (x * rhs.x) + (y * rhs.y) + (z * rhs.z);
}



// MultMtx
//
/*_Vector3<T> Vector3::MultMtx(const Mtx33& rhs) const
{
VecFx32 tmp;

VEC_Set(&tmp, x, y, z);

MTX_MultVec33(&tmp, &rhs, &tmp);

return Vector3(tmp.x, tmp.y, tmp.z);
}*/


// Lerp
//
template <class T> _Vector3<T> _Vector3<T>::Lerp(const _Vector3<T>& rhs, const T time) const
{
	_Vector3<T> tmp = (rhs - *this) * time;
	return *this + tmp;
}



//
// Static Functions
//


// Magnitude
//
template <class T> T _Vector3<T>::Magnitude(_Vector3<T> v)
{
	return v.Magnitude();
}



// MagnitudeSqr
//
template <class T> T _Vector3<T>::MagnitudeSqr(_Vector3<T> v)
{
	return v.MagnitudeSqr();
}



// Normalise
//
template <class T> _Vector3<T> _Vector3<T>::Normalise(_Vector3<T> v)
{
	v.Normalise();
	return v;
}



// Cross
//
template <class T> _Vector3<T> _Vector3<T>::Cross(_Vector3<T> lhs, _Vector3<T> rhs)
{
	return lhs.Cross(rhs);
}



// Dot
//
template <class T> T _Vector3<T>::Dot(_Vector3<T> lhs, _Vector3<T> rhs)
{
	return lhs.Dot(rhs);
}



// MultMtx
//
//Vector3 Vector3::MultMtx(Vector3 v, Mtx33 m)
//{
//	VecFx32 tmp = *(VecFx32 *)(&v);
//
//	MTX_MultVec33(&tmp, &m, &tmp);
//
//	return Vector3(tmp);
//}



// Lerp
//
template <class T> _Vector3<T> _Vector3<T>::Lerp(_Vector3<T> lhs, _Vector3<T> rhs, T time)
{
	return lhs.Lerp(rhs, time);
}



// Returns the points data as a string.
//
template <class T> const char *_Vector3<T>::ToString() const
{
	static char buffer[256];
#if defined(PLATFORM_PC) || defined(PLATFORM_360)
	sprintf_s(buffer, "%i, %i, %i", (s32)x, (s32)y, (s32)z);
#else
	sprintf(buffer, "%i, %i, %i", (s32)x, (s32)y, (s32)z);
	//sprintf_s(buffer, "%i, %i, %i", (s32)x, (s32)y, (s32)z);
#endif
	return buffer;
}

// CatmullRom
//
template <class T> _Vector3<T> _Vector3<T>::CatmullRom(const _Vector3<T> &p0, const _Vector3<T> &p1, const _Vector3<T> &p2, const _Vector3<T> &p3, T time)
{
	T time2 = time * time;
	T time3 = time2 * time;

	return ((p1 * 2) + (-p0 + p2) * time +
		(p0*2 - p1*5 + p2*4 - p3) * time2 +
		(-p0 + p1*3- p2*3 + p3) * time3) / 2;
}

//// Friends.
////
//ErrorLogManager& operator << (ErrorLogManager& elm, Vector3& vector)
//{
//    elm << vector.ToString();
//    return elm;
//}
//
//
//
//// Friends.
////
//ErrorLogManager& operator << (ErrorLogManager& elm, const Vector3& vector)
//{
//    elm << vector.ToString();
//    return elm;
//}

Vector4.inl:

// ------------------------------------------------------------------------------------------------
//
//  File: Vector3.inl
//
//      Description     - Implementation of the inline Vector3 functions
//      Author          - Aidan Millott
//
//  Modifications:
//  --------------
//      July 29, 2009   - Initial creation.
//		July 30, 2009	- Woody Updated to templates
//
// ------------------------------------------------------------------------------------------------

// Operator +
//

template <class T> const _Vector4<T> _Vector4<T>::One = _Vector4<T>(1.0f,1.0f,1.0f,1.0f);
template <class T> const _Vector4<T> _Vector4<T>::Zero = _Vector4<T>(0.0f,0.0f,0.0f,0.0f); 


template <class T> _Vector4<T> _Vector4<T>::operator + ( const _Vector4<T>& rhs ) const
{
	return _Vector4<T>( x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w );
}

template <class T> _Vector4<T> _Vector4<T>::operator + ( T rhs ) const
{
	return _Vector4<T>( x + rhs, y + rhs, z + rhs, w + rhs );
}



// Operator -
//
template <class T> _Vector4<T> _Vector4<T>::operator - ( const _Vector4<T>& rhs ) const
{
	return _Vector4<T>( x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w );
}

template <class T> _Vector4<T> _Vector4<T>::operator - ( T rhs ) const
{
	return _Vector4<T>( x - rhs, y - rhs, z - rhs, w - rhs );
}



// Operator *
//
template <class T> _Vector4<T> _Vector4<T>::operator * ( const T& rhs ) const
{
	return	_Vector4<T>
		(
		x * rhs,
		y * rhs,
		z * rhs,
		w * rhs
		);
}

template <class T> _Vector4<T> _Vector4<T>::operator * (const _Vector4<T>& val) const
{
	return _Vector4<T>
		(
		x * val.x,
		y * val.y,
		z * val.z,
		w * val.w
		);
}

// Operator >>/<<
template <class T> _Vector4<T> _Vector4<T>::operator >> ( const u32 val ) const
{
	return	_Vector4<T>
		(
		x>>val,
		y>>val,
		z>>val,
		w>>val
		);
}


template <class T> _Vector4<T> _Vector4<T>::operator << ( const u32 val ) const
{
	return	_Vector4<T>
		(
		x<<val,
		y<<val,
		z<<val,
		w<<val
		);
}

// Operator /
//

template <class T> _Vector4<T> _Vector4<T>::operator / ( const T& rhs ) const
{
	T inverse = 1 / rhs;
	return	_Vector4<T>
		(
		x * inverse,
		y * inverse,
		z * inverse,
		w * inverse
		);
}



// Operator +=
//
template <class T> _Vector4<T>& _Vector4<T>::operator += (const _Vector4<T>& rhs )
{
	x += rhs.x;
	y += rhs.y;
	z += rhs.z;
	w += rhs.w;

	return *this;
}

// Operator >>=/<<=

template <class T> _Vector4<T>& _Vector4<T>::operator >>= (const u32 val )
{
	x >>= val;
	y >>= val;
	z >>= val;
	w >>= val;

	return *this;
}

template <class T> _Vector4<T>& _Vector4<T>::operator <<= (const u32 val )
{
	x <<= val;
	y <<= val;
	z <<= val;
	w <<= val;

	return *this;
}



// Operator -=
//
template <class T> _Vector4<T>& _Vector4<T>::operator -= ( const _Vector4<T>& rhs )
{
	x -= rhs.x;
	y -= rhs.y;
	z -= rhs.z;
	w -= rhs.w;

	return *this;
}



// Operator *=
//
template <class T> _Vector4<T>& _Vector4<T>::operator *= ( const T val )
{
	x *= val;
	y *= val;
	z *= val;
	w *= val;

	return *this;
}

template <class T> _Vector4<T> _Vector4<T>::operator *= (const _Vector4<T>& val)
{
	x *= val.x;
	y *= val.y;
	z *= val.z;
	w *= val.w;

	return *this;
}


// Operator /=
template <class T> _Vector4<T>& _Vector4<T>::operator /= ( const T val )
{
	*this *= 1 / val;

	return *this;
}



// Operator -
//
template <class T> _Vector4<T> _Vector4<T>::operator - () const
{
	return _Vector4<T>(-x, -y, -z, -w);
}



// Operator ==
template <class T> bool _Vector4<T>::operator == (const _Vector4<T> &v) const
{
	return (x == v.x && y == v.y && z == v.z && w == v.w);
}


// Operator !=
template <class T> bool _Vector4<T>::operator != (const _Vector4<T> &v) const
{
	return (x != v.x || y != v.y || z != v.z || w != v.w);
}

template <class T> bool _Vector4<T>::Equals(const _Vector4 &v, float tolerance) const
{
	return
		BETWEEN(x-v.x, -tolerance, tolerance) &&
		BETWEEN(y-v.y, -tolerance, tolerance) &&
		BETWEEN(z-v.z, -tolerance, tolerance) &&
		BETWEEN(w-v.w, -tolerance, tolerance) ;
}

// Magnitude
//
template <class T> T _Vector4<T>::Magnitude() const
{
	return Math::Sqrt(MagnitudeSqr());
}



// MagnitudeSqr
//
template <class T> T _Vector4<T>::MagnitudeSqr() const
{
	return Dot(*this);
}



// Normalise
//
template <class T> float _Vector4<T>::Normalise()
{
	if(x == 0 && y == 0 && z == 0)
		return 0;

	T denom = Magnitude();
	if(denom != 0)
	{
		*this /= denom;
	}
	else
	{
		//wasn't 0, but was very small, multiply by a large number
		*this *= 1000000;
		Normalise();
	}

	return denom;
}




// Dot
//
template <class T> T _Vector4<T>::Dot(const _Vector4<T>& rhs) const
{
	return (x * rhs.x) + (y * rhs.y) + (z * rhs.z) + (w * rhs.w);
}



// Lerp
//
template <class T> _Vector4<T> _Vector4<T>::Lerp(const _Vector4<T>& rhs, const T time) const
{
	_Vector4<T> tmp = (rhs - *this) * time;
	return *this + tmp;
}



//
// Static Functions
//


// Magnitude
//
template <class T> T _Vector4<T>::Magnitude(_Vector4<T> v)
{
	return v.Magnitude();
}



// MagnitudeSqr
//
template <class T> T _Vector4<T>::MagnitudeSqr(_Vector4<T> v)
{
	return v.MagnitudeSqr();
}



// Normalise
//
template <class T> _Vector4<T> _Vector4<T>::Normalise(_Vector4<T> v)
{
	v.Normalise();
	return v;
}



// Dot
//
template <class T> T _Vector4<T>::Dot(_Vector4<T> lhs, _Vector4<T> rhs)
{
	return lhs.Dot(rhs);
}



// MultMtx
//
//Vector3 Vector3::MultMtx(Vector3 v, Mtx33 m)
//{
//	VecFx32 tmp = *(VecFx32 *)(&v);
//
//	MTX_MultVec33(&tmp, &m, &tmp);
//
//	return Vector3(tmp);
//}



// Lerp
//
template <class T> _Vector4<T> _Vector4<T>::Lerp(_Vector4<T> lhs, _Vector4<T> rhs, T time)
{
	return lhs.Lerp(rhs, time);
}



// Returns the points data as a string.
//
template <class T> const char *_Vector4<T>::ToString() const
{
	static char buffer[256];
#if defined(PLATFORM_PC) || defined(PLATFORM_360)
	sprintf_s
#else
	sprintf
#endif
		(buffer, "%f, %f, %f, %f", (float)x, (float)y, (float)z);
	return buffer;
}

Rectangle.inl and WeakComponentPtr.inl are unfortunately empty.

Xcode configurations

A portion of configurations for the said game engine are present in the root of the HD paid version.

Mortar_Release_OSX.xcconfig:

#include "Mortar_Common_OSX.xcconfig"
#include "Mortar_Common_Release.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) NDEBUG=1 OSX_SYSTEM_DEFINE MAGIC_3D RENDERING_API=GLES2 USE_HTTP_CLIENT CURL_STATICLIB

Mortar_Release_iOS_GLES1.xcconfig:

#include "Mortar_Common_iOS.xcconfig"
#include "Mortar_Common_Release.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) NDEBUG=1 IPHONE_SYSTEM_DEFINE MAGIC_3D RENDERING_API=GLES1 USE_HTTP_CLIENT

Mortar_Release_iOS.xcconfig:

#include "Mortar_Common_iOS.xcconfig"
#include "Mortar_Common_Release.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) NDEBUG=1 IPHONE_SYSTEM_DEFINE MAGIC_3D RENDERING_API=GLES2 USE_HTTP_CLIENT USE_FREE_IMAGE_LIB

MortarPaths.xcconfig:

ALWAYS_SEARCH_USER_PATHS = NO

ProjectMortarDir=$(RootProjectsDir)/Engines/MortarWorking/src
FrameworksProjectDir=$(RootProjectsDir)/Frameworks

MORTAR_HEADER_SEARCH_PATHS = "$(ProjectMortarDir)/Source" "$(ProjectMortarDir)/3rdParty" "$(ProjectMortarDir)/3rdParty/agg-2.4/include" "$(ProjectMortarDir)/3rdParty/libzip/libzip-0.10/lib" "$(ProjectMortarDir)/3rdParty/freetype/includes_244" "$(ProjectEntityDir)/Source" "$(ProjectMortarDir)/3rdParty/Ogg/libogg-1.2.0/include/"

FRAMEWORKS_HEADER_SEARCH_PATHS = "$(FrameworksProjectDir)/Entity/Source" "$(FrameworksProjectDir)/GameProperty/Source";

HEADER_SEARCH_PATHS = $(inherited) $(MORTAR_HEADER_SEARCH_PATHS) $(FRAMEWORKS_HEADER_SEARCH_PATHS)
LIBRARY_SEARCH_PATHS = $(inherited) "$(ProjectMortarDir)/3rdParty/libcurl/iOS/libcurl/lib" "$(ProjectMortarDir)/3rdParty/freetype/libs"

Mortar_Paths_GameCore.xcconfig

#include "Mortar_Paths.xcconfig"

HEADER_SEARCH_PATHS = $(inherited) "$(ProjectMortarDir)/Modules/GameCoreLib" $(MORTAR_HEADER_SEARCH_PATHS)
LIBRARY_SEARCH_PATHS = $(inherited) "$(ProjectMortarDir)/3rdParty/libcurl/iOS/libcurl/lib" "$(ProjectMortarDir)/3rdParty/freetype/libs"

Mortar_Debug_OSX.xcconfig

#include "Mortar_Common_OSX.xcconfig"
#include "Mortar_Common_Debug.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) _DEBUG=1 DEBUG=1 ENABLE_ASSERTS OSX_SYSTEM_DEFINE MAGIC_3D RENDERING_API=GLES2 USE_HTTP_CLIENT CURL_STATICLIB GAME_PROPERTY_EDITOR

Mortar_Debug_iOS_GLES1.xcconfig:

#include "Mortar_Common_iOS.xcconfig"
#include "Mortar_Common_Debug.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) _DEBUG=1 DEBUG=1 ENABLE_ASSERTS IPHONE_SYSTEM_DEFINE MAGIC_3D RENDERING_API=GLES1 USE_HTTP_CLIENT

Mortar_Debug_iOS.xcconfig:

#include "Mortar_Common_iOS.xcconfig"
#include "Mortar_Common_Debug.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) _DEBUG=1 DEBUG=1 ENABLE_ASSERTS IPHONE_SYSTEM_DEFINE MAGIC_3D RENDERING_API=GLES2 USE_HTTP_CLIENT GAME_PROPERTY_EDITOR USE_FREE_IMAGE_LIB

Mortar_Common_Release.xcconfig:

#include "Mortar_Common.xcconfig"

COPY_PHASE_STRIP = YES
GCC_OPTIMIZATION_LEVEL = s
OTHER_CFLAGS = -DNS_BLOCK_ASSERTIONS=1
VALIDATE_PRODUCT = YES

Mortar_Common_OSX.xcconfig:

SDKROOT = macosx

OTHER_LDFLAGS = $(inherited) -ObjC

Mortar_Common_iOS.xcconfig:

SDKROOT = iphoneos
OTHER_LDFLAGS = $(inherited) -ObjC
IPHONEOS_DEPLOYMENT_TARGET = 5.0
TARGETED_DEVICE_FAMILY = 1,2
ARCHS = armv7

Mortar_Common_Debug.xcconfig:

#include "Mortar_Common.xcconfig"

COPY_PHASE_STRIP = NO
GCC_OPTIMIZATION_LEVEL = 0
VALIDATE_PRODUCT = NO

Mortar_Common.xcconfig:

GCC_SYMBOLS_PRIVATE_EXTERN = NO
GCC_C_LANGUAGE_STANDARD = c11
CLANG_CXX_LANGUAGE_STANDARD = gnu++11
CLANG_CXX_LIBRARY = libc++


GCC_ENABLE_CPP_EXCEPTIONS = NO
GCC_ENABLE_CPP_RTTI = NO