Skip to content

Commit

Permalink
Fixed some server-side crashes and rewrote some code to make it more …
Browse files Browse the repository at this point in the history
…manageable
  • Loading branch information
Ohmnivore committed Jun 6, 2014
1 parent c003e9e commit b10b959
Show file tree
Hide file tree
Showing 33 changed files with 297 additions and 211 deletions.
5 changes: 3 additions & 2 deletions Client/export/windows/cpp/bin/config.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version=0.2.1name=Ohmnivore
version=0.2.1
name=Ohmnivore
team=1
ip=
masterserver=http://skullrush.elementfx.com/laravel/public/
fullscreen=false
showping=true
crashdump=true
crashdump=true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ At the moment the source code is a mess. I'll take a couple of weeks to clean al
## Gameplay:
* New maps
* footstool jumping
* rework splasher
* rework splasher + shotgun
* custom tiles


Expand Down
2 changes: 2 additions & 0 deletions Server/Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

<!--------------------------------HAXEDEFINES----------------------------------->

<haxedef name="SERVER" />

<haxedef name="HXCPP_STACK_TRACE" />
<haxedef name="HXCPP_STACK_LINE" />
<haxedef name="HXCPP_DEBUG_LINK" />
Expand Down
15 changes: 9 additions & 6 deletions Server/Server.hxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,28 @@
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="C:\HaxeToolkit\haxe\lib\crashdumper\git" />
<class path="C:\HaxeToolkit\haxe\lib\flixel-addons\git" />
<class path="C:\HaxeToolkit\haxe\lib\openfl\2,0,0" />
<class path="C:\HaxeToolkit\haxe\lib\flixel\3,3,4" />
<class path="C:\HaxeToolkit\haxe\lib\lime\1,0,0" />
<class path="source" />
<class path="..\Shared\code" />
<class path="C:\HaxeToolkit\haxe\lib\openfl\2,0,0\backends\native" />
<class path="export\windows\cpp\haxe" />
</classpaths>
<!-- Build options -->
<build>
<option directives="FLX_NO_GAMEPAD&#xA;FLX_NO_FOCUS_LOST_SCREEN&#xA;tools=1.4.0&#xA;HXCPP_STACK_TRACE&#xA;FLX_NO_DEBUG&#xA;lime_native&#xA;no-compilation&#xA;HXCPP_STACK_LINE&#xA;HXCPP_DEBUG_LINK&#xA;FLX_NO_TOUCH&#xA;display&#xA;FLX_RENDER_TILE&#xA;windows&#xA;desktop" />
<option directives="crashdumper=&#xA;flixel-addons=1.1.0&#xA;openfl=2.0.0&#xA;flixel=3.3.4&#xA;lime=1.0.0&#xA;FLX_NO_GAMEPAD&#xA;SERVER&#xA;native&#xA;openfl-native&#xA;FLX_NO_FOCUS_LOST_SCREEN&#xA;tools=1.5.4&#xA;HXCPP_CHECK_POINTER&#xA;HXCPP_STACK_TRACE&#xA;lime_native&#xA;no-compilation&#xA;HXCPP_STACK_LINE&#xA;HXCPP_DEBUG_LINK&#xA;FLX_NO_TOUCH&#xA;safeMode&#xA;display&#xA;FLX_RENDER_TILE&#xA;windows&#xA;desktop" />
<option flashStrict="False" />
<option noInlineOnDebug="False" />
<option mainClass="ApplicationMain" />
<option enabledebug="False" />
<option additional="--no-output&#xA;--macro allowPackage('flash')&#xA;--macro keep(&quot;Main&quot;)" />
<option additional="--no-output&#xA;--remap flash:openfl&#xA;--macro keep(&quot;Main&quot;)" />
</build>
<!-- haxelib libraries -->
<haxelib>
<library name="lime:0.9.7" />
<library name="flixel:3.3.1" />
<library name="openfl" />
<library name="flixel-addons" />
<!-- example: <library name="..." /> -->
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
Expand Down
Binary file modified Server/export/windows/cpp/bin/SkullRushServer.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions Server/export/windows/cpp/bin/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ crashdump=true
manifesturl=null
#https://dl.dropboxusercontent.com/u/229424261/skullrush/manifest.json

maps=Test, TwinCapture
maps=TwinCapture, Test

masterserver=http://skullrush.elementfx.com/laravel/public/

Expand All @@ -27,5 +27,5 @@ ffa_maxtime=10
ffa_maxkills=30

#ctf config
ctf_maxtime=8
ctf_maxcaps=5
ctf_maxtime=5
ctf_maxcaps=3
2 changes: 2 additions & 0 deletions Server/source/FlxBulletExt.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ;
import networkobj.NEmitter;
import ext.FlxBulletExtBase;
import ext.FlxWeaponExt;

/**
* ...
Expand Down
1 change: 1 addition & 0 deletions Server/source/Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import flixel.util.FlxTimer;
import haxe.Unserializer;
import networkobj.NEmitter;
import networkobj.NWeapon;
import ext.FlxWeaponExt;

/**
* ...
Expand Down
2 changes: 2 additions & 0 deletions Server/source/SkullServer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import haxe.io.BytesInput;
import networkobj.NReg;
import sys.io.File;
import hxudp.UdpSocket;
import ext.FlxMarkup;
import ext.FlxTextExt;

/**
* ...
Expand Down
155 changes: 94 additions & 61 deletions Server/source/entities/Flag.hx
Original file line number Diff line number Diff line change
@@ -1,86 +1,149 @@
package entities;
import entities.Flag.FlagSprite;
import entities.HealthPack.Pack;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.util.FlxTimer;
import gamemodes.CTF;
import haxe.xml.Fast;
import networkobj.NFlxSprite;
import networkobj.NReg;
import networkobj.NSprite;
import networkobj.NTemplate;
import flixel.FlxSprite;
import ext.FlxMarkup;

/**
* ...
* @author Ohmnivore
*/
class Flag extends NSprite
{
public var data:Fast;
static public var TEMPL:NTemplate;
static public var taken_flags:Map<Player, Flag>;

public var holder:Holder;

public var team:Int;
public var taken:Bool;
public var owner:Player;
public var graphic:String;

public function new(Data:Fast)
public function new(X:Float, Y:Float, TeamFlag:Int, Graphic:String)
{
data = Data;

team = Std.parseInt(data.att.team);
team = TeamFlag;
graphic = Graphic;
taken = false;

var templ:NTemplate = new NTemplate(data.att.graphic, 0);
NReg.registerTemplate(templ);
super(X, Y, TEMPL, FlagSprite);

super(Std.parseInt(data.att.x), Std.parseInt(data.att.y), templ, NFlxSprite);

holder = new Holder(data, this);

var gm:CTF = cast(Reg.gm, CTF);
gm.flags.add(s);
holder = new Holder(X, Y + 26,
team, this, Graphic);

s.x += 4;

s.immovable = true;
}

override public function announce(PlayerID:Int):Void
{
super.announce(PlayerID);

setImage(PlayerID, graphic);
}

static public function makeFromXML(D:Fast):Flag
{
return new Flag(D);
return new Flag(Std.parseInt(D.att.x), Std.parseInt(D.att.y),
Std.parseInt(D.att.team), D.att.graphic);
}

static public function init():Void
{
TEMPL = new NTemplate("assets/images/flag_g.png", 0);
NReg.registerTemplate(TEMPL);

taken_flags = new Map<Player, Flag>();
Holder.init();
}
}

class FlagSprite extends NFlxSprite
{
public var flag:Flag;

public function new(X:Float, Y:Float, GraphicString:String, Parent:Flag)
{
super(X, Y, GraphicString, Parent);

flag = Parent;
}

override public function update():Void
{
FlxG.overlap(Reg.state.players, this, collideFlag);
super.update();

checkIfFall();
followOwner();
}

static public function updateFlags():Void
public function checkIfFall():Void
{
for (f in taken_flags.iterator())
if (flag.s.y >= Reg.state.collidemap.y + Reg.state.collidemap.height + FlxG.height / 2)
{
if (f.owner != null)
returnFlag(null, flag);
}
}

public function collideFlag(P:Player, F:FlagSprite):Void
{
if (P.alive)
{
var f:Flag = cast(NReg.sprites.get(F.ID), Flag);

if (P.team == f.team)
{
if (f.owner.alive)
if (f.taken && f.owner == null)
{
f.s.x = f.owner.x;
f.s.y = f.owner.y;
//f.s.velocity.x = f.owner.velocity.x;
//f.s.velocity.y = f.owner.velocity.y;
returnFlag(P, f);
}

else
}

else
{
if (f.owner == null)
{
Flag.taken_flags.remove(f.owner);
f.owner = null;
takeFlag(P, f);
}
}
}
}

public function followOwner():Void
{
if (flag.owner != null)
{
if (flag.owner.alive)
{
flag.s.x = flag.owner.x;
flag.s.y = flag.owner.y;
}

else
{
Flag.taken_flags.remove(flag.owner);
flag.owner = null;
}
}
}

static public function takeFlag(P:Player, F:Flag):Void
{
F.owner = P;

F.taken = true;

taken_flags.set(P, F);
Flag.taken_flags.set(P, F);

var s:String = P.name + " took the flag!";
Reg.server.announce(s, [new FlxMarkup(0, P.name.length, false, P.header.color)]);
Expand All @@ -98,7 +161,7 @@ class Flag extends NSprite
F.taken = false;
if (F.owner != null)
{
taken_flags.remove(F.owner);
Flag.taken_flags.remove(F.owner);
F.owner = null;
}

Expand All @@ -112,34 +175,4 @@ class Flag extends NSprite
gm.setPlayerScoreboard(P);
}
}

static public function collideFlag(P:Player, F:FlxSprite):Void
{
if (P.alive)
{
var f:Flag = cast(NReg.sprites.get(F.ID), Flag);

if (P.team == f.team)
{
if (f.taken && f.owner == null)
{
returnFlag(P, f);
}
}

else
{
if (f.owner == null)
{
takeFlag(P, f);
}
}
}
}

static public function init():Void
{
taken_flags = new Map<Player, Flag>();
Holder.init();
}
}
Loading

0 comments on commit b10b959

Please sign in to comment.