Merge pull request #5 from iamgreaser/master
0.76 protocol support + this SHOULD compile properly for distros which don't have static fltk libs
This commit is contained in:
commit
e8b3dc78fe
@ -23,6 +23,7 @@ openspades_LDADD += $(FLTK_LIBS)
|
|||||||
openspades_LDADD += $(ZLIB_LIBS)
|
openspades_LDADD += $(ZLIB_LIBS)
|
||||||
# openspades_LDADD += $(PNG_LIBS)
|
# openspades_LDADD += $(PNG_LIBS)
|
||||||
openspades_LDADD += $(WIN32_LIBS)
|
openspades_LDADD += $(WIN32_LIBS)
|
||||||
|
openspades_LDADD += -ldl
|
||||||
|
|
||||||
# pkg-config doesn't seem to work...
|
# pkg-config doesn't seem to work...
|
||||||
# openspades_LDADD += -ljpeg
|
# openspades_LDADD += -ljpeg
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "TCGameMode.h"
|
#include "TCGameMode.h"
|
||||||
|
#include "../Core/Settings.h"
|
||||||
|
|
||||||
|
SPADES_SETTING(ne_version, "3");
|
||||||
|
|
||||||
namespace spades {
|
namespace spades {
|
||||||
namespace client {
|
namespace client {
|
||||||
@ -299,6 +302,11 @@ namespace spades {
|
|||||||
Disconnect();
|
Disconnect();
|
||||||
SPAssert(status == NetClientStatusNotConnected);
|
SPAssert(status == NetClientStatusNotConnected);
|
||||||
|
|
||||||
|
if((int)ne_version != 3 && (int)ne_version != 4)
|
||||||
|
SPRaise("Invalid ne_version, should be 3 or 4");
|
||||||
|
|
||||||
|
protoVersion = (int)ne_version;
|
||||||
|
|
||||||
if(hostname.find("aos:///") == 0){
|
if(hostname.find("aos:///") == 0){
|
||||||
hostname = hostname.substr(7);
|
hostname = hostname.substr(7);
|
||||||
}else if(hostname.find("aos://") == 0){
|
}else if(hostname.find("aos://") == 0){
|
||||||
@ -328,7 +336,7 @@ namespace spades {
|
|||||||
|
|
||||||
savedPackets.clear();
|
savedPackets.clear();
|
||||||
|
|
||||||
peer = enet_host_connect(host, &address, 1, 3);
|
peer = enet_host_connect(host, &address, 1, (int)ne_version);
|
||||||
if(peer == NULL){
|
if(peer == NULL){
|
||||||
SPRaise("Failed to create ENet peer");
|
SPRaise("Failed to create ENet peer");
|
||||||
}
|
}
|
||||||
@ -653,8 +661,20 @@ namespace spades {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypeWorldUpdate:
|
case PacketTypeWorldUpdate:
|
||||||
|
{
|
||||||
//reader.DumpDebug();
|
//reader.DumpDebug();
|
||||||
|
int bytesPerEntry = 24;
|
||||||
|
if((int)ne_version == 4)
|
||||||
|
bytesPerEntry++;
|
||||||
|
|
||||||
|
int entries = reader.GetData().size() / bytesPerEntry;
|
||||||
for(int i = 0; i < 32; i++){
|
for(int i = 0; i < 32; i++){
|
||||||
|
int idx = i;
|
||||||
|
if((int)ne_version == 4)
|
||||||
|
{
|
||||||
|
idx = reader.ReadByte();
|
||||||
|
SPAssert(idx >= 0 && idx < 32);
|
||||||
|
}
|
||||||
Vector3 pos, front;
|
Vector3 pos, front;
|
||||||
pos.x = reader.ReadFloat();
|
pos.x = reader.ReadFloat();
|
||||||
pos.y = reader.ReadFloat();
|
pos.y = reader.ReadFloat();
|
||||||
@ -680,7 +700,7 @@ namespace spades {
|
|||||||
SPAssert(!isnan(front.z));
|
SPAssert(!isnan(front.z));
|
||||||
SPAssert(front.GetLength() < 40.f);
|
SPAssert(front.GetLength() < 40.f);
|
||||||
if(GetWorld()){
|
if(GetWorld()){
|
||||||
p = GetWorld()->GetPlayer(i);
|
p = GetWorld()->GetPlayer(idx);
|
||||||
if(p){
|
if(p){
|
||||||
if(p != GetWorld()->GetLocalPlayer()){
|
if(p != GetWorld()->GetLocalPlayer()){
|
||||||
p->SetPosition(pos);
|
p->SetPosition(pos);
|
||||||
@ -691,6 +711,7 @@ namespace spades {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SPAssert(reader.ReadRemainingData().empty());
|
SPAssert(reader.ReadRemainingData().empty());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypeInputData:
|
case PacketTypeInputData:
|
||||||
if(!GetWorld())
|
if(!GetWorld())
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "IWorldListener.h"
|
#include "IWorldListener.h"
|
||||||
#include "../Core/Exception.h"
|
#include "../Core/Exception.h"
|
||||||
#include "../Core/Debug.h"
|
#include "../Core/Debug.h"
|
||||||
|
#include "../Core/Settings.h"
|
||||||
|
|
||||||
namespace spades {
|
namespace spades {
|
||||||
namespace client {
|
namespace client {
|
||||||
@ -130,9 +131,9 @@ namespace spades {
|
|||||||
world->GetListener()->PlayerReloadingWeapon(owner);
|
world->GetListener()->PlayerReloadingWeapon(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RifleWeapon: public Weapon {
|
class RifleWeapon3: public Weapon {
|
||||||
public:
|
public:
|
||||||
RifleWeapon(World*w,Player*p):Weapon(w,p){}
|
RifleWeapon3(World*w,Player*p):Weapon(w,p){}
|
||||||
virtual std::string GetName() { return "Rifle"; }
|
virtual std::string GetName() { return "Rifle"; }
|
||||||
virtual float GetDelay() { return 0.5f; }
|
virtual float GetDelay() { return 0.5f; }
|
||||||
virtual int GetClipSize() { return 10; }
|
virtual int GetClipSize() { return 10; }
|
||||||
@ -156,9 +157,9 @@ namespace spades {
|
|||||||
virtual int GetPelletSize() { return 1; }
|
virtual int GetPelletSize() { return 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class SMGWeapon: public Weapon {
|
class SMGWeapon3: public Weapon {
|
||||||
public:
|
public:
|
||||||
SMGWeapon(World*w,Player*p):Weapon(w,p){}
|
SMGWeapon3(World*w,Player*p):Weapon(w,p){}
|
||||||
virtual std::string GetName() { return "SMG"; }
|
virtual std::string GetName() { return "SMG"; }
|
||||||
virtual float GetDelay() { return 0.1f; }
|
virtual float GetDelay() { return 0.1f; }
|
||||||
virtual int GetClipSize() { return 30; }
|
virtual int GetClipSize() { return 30; }
|
||||||
@ -182,9 +183,9 @@ namespace spades {
|
|||||||
virtual int GetPelletSize() { return 1; }
|
virtual int GetPelletSize() { return 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShotgunWeapon: public Weapon {
|
class ShotgunWeapon3: public Weapon {
|
||||||
public:
|
public:
|
||||||
ShotgunWeapon(World*w,Player*p):Weapon(w,p){}
|
ShotgunWeapon3(World*w,Player*p):Weapon(w,p){}
|
||||||
virtual std::string GetName() { return "Shotgun"; }
|
virtual std::string GetName() { return "Shotgun"; }
|
||||||
virtual float GetDelay() { return 1.f; }
|
virtual float GetDelay() { return 1.f; }
|
||||||
virtual int GetClipSize() { return 6; }
|
virtual int GetClipSize() { return 6; }
|
||||||
@ -199,10 +200,8 @@ namespace spades {
|
|||||||
case HitTypeArms: return 16;
|
case HitTypeArms: return 16;
|
||||||
case HitTypeLegs: return 16;
|
case HitTypeLegs: return 16;
|
||||||
case HitTypeBlock:
|
case HitTypeBlock:
|
||||||
if(distance < 15.f)
|
// Actually, you cast a hit per pallet. This value is a guess, by the way. --GM
|
||||||
return 100;
|
return 34;
|
||||||
else
|
|
||||||
return (int)(15.f / distance * 100.f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual Vector3 GetRecoil () {
|
virtual Vector3 GetRecoil () {
|
||||||
@ -212,19 +211,115 @@ namespace spades {
|
|||||||
virtual int GetPelletSize() { return 8; }
|
virtual int GetPelletSize() { return 8; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RifleWeapon4: public Weapon {
|
||||||
|
public:
|
||||||
|
RifleWeapon4(World*w,Player*p):Weapon(w,p){}
|
||||||
|
virtual std::string GetName() { return "Rifle"; }
|
||||||
|
virtual float GetDelay() { return 0.6f; }
|
||||||
|
virtual int GetClipSize() { return 8; }
|
||||||
|
virtual int GetMaxStock() { return 48; }
|
||||||
|
virtual float GetReloadTime() { return 2.5f; }
|
||||||
|
virtual bool IsReloadSlow() { return false; }
|
||||||
|
virtual WeaponType GetWeaponType() { return RIFLE_WEAPON; }
|
||||||
|
virtual int GetDamage(HitType type, float distance) {
|
||||||
|
switch(type){
|
||||||
|
// These are the 0.75 damage values.
|
||||||
|
// To be honest, we don't need this information, as the server decides the damage.
|
||||||
|
// EXCEPT for blocks, that is.
|
||||||
|
// --GM
|
||||||
|
case HitTypeTorso: return 49;
|
||||||
|
case HitTypeHead: return 100;
|
||||||
|
case HitTypeArms: return 33;
|
||||||
|
case HitTypeLegs: return 33;
|
||||||
|
case HitTypeBlock: return 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual Vector3 GetRecoil () {
|
||||||
|
return MakeVector3(0.0001f, 0.075f, 0.f);
|
||||||
|
}
|
||||||
|
virtual float GetSpread() { return 0.004f; }
|
||||||
|
virtual int GetPelletSize() { return 1; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class SMGWeapon4: public Weapon {
|
||||||
|
public:
|
||||||
|
SMGWeapon4(World*w,Player*p):Weapon(w,p){}
|
||||||
|
virtual std::string GetName() { return "SMG"; }
|
||||||
|
virtual float GetDelay() { return 0.1f; }
|
||||||
|
virtual int GetClipSize() { return 30; }
|
||||||
|
virtual int GetMaxStock() { return 150; }
|
||||||
|
virtual float GetReloadTime() { return 2.5f; }
|
||||||
|
virtual bool IsReloadSlow() { return false; }
|
||||||
|
virtual WeaponType GetWeaponType() { return SMG_WEAPON; }
|
||||||
|
virtual int GetDamage(HitType type, float distance) {
|
||||||
|
switch(type){
|
||||||
|
case HitTypeTorso: return 29;
|
||||||
|
case HitTypeHead: return 75;
|
||||||
|
case HitTypeArms: return 18;
|
||||||
|
case HitTypeLegs: return 18;
|
||||||
|
case HitTypeBlock: return 34;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual Vector3 GetRecoil () {
|
||||||
|
return MakeVector3(0.00005f, 0.0125f, 0.f);
|
||||||
|
}
|
||||||
|
virtual float GetSpread() { return 0.012f; }
|
||||||
|
virtual int GetPelletSize() { return 1; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class ShotgunWeapon4: public Weapon {
|
||||||
|
public:
|
||||||
|
ShotgunWeapon4(World*w,Player*p):Weapon(w,p){}
|
||||||
|
virtual std::string GetName() { return "Shotgun"; }
|
||||||
|
virtual float GetDelay() { return 0.8f; }
|
||||||
|
virtual int GetClipSize() { return 8; }
|
||||||
|
virtual int GetMaxStock() { return 48; }
|
||||||
|
virtual float GetReloadTime() { return 0.4f; }
|
||||||
|
virtual bool IsReloadSlow() { return true; }
|
||||||
|
virtual WeaponType GetWeaponType() { return SHOTGUN_WEAPON; }
|
||||||
|
virtual int GetDamage(HitType type, float distance) {
|
||||||
|
switch(type){
|
||||||
|
case HitTypeTorso: return 27;
|
||||||
|
case HitTypeHead: return 37;
|
||||||
|
case HitTypeArms: return 16;
|
||||||
|
case HitTypeLegs: return 16;
|
||||||
|
case HitTypeBlock:
|
||||||
|
return 34;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual Vector3 GetRecoil () {
|
||||||
|
return MakeVector3(0.0002f, 0.075f, 0.f);
|
||||||
|
}
|
||||||
|
virtual float GetSpread() { return 0.036f; }
|
||||||
|
virtual int GetPelletSize() { return 8; }
|
||||||
|
};
|
||||||
|
|
||||||
Weapon *Weapon::CreateWeapon(WeaponType type, Player *p) {
|
Weapon *Weapon::CreateWeapon(WeaponType type, Player *p) {
|
||||||
SPADES_MARK_FUNCTION();
|
SPADES_MARK_FUNCTION();
|
||||||
|
|
||||||
switch(type){
|
if(spades::client::protoVersion == 4) {
|
||||||
|
switch(type) {
|
||||||
case RIFLE_WEAPON:
|
case RIFLE_WEAPON:
|
||||||
return new RifleWeapon(p->GetWorld(), p);
|
return new RifleWeapon4(p->GetWorld(), p);
|
||||||
case SMG_WEAPON:
|
case SMG_WEAPON:
|
||||||
return new SMGWeapon(p->GetWorld(), p);
|
return new SMGWeapon4(p->GetWorld(), p);
|
||||||
case SHOTGUN_WEAPON:
|
case SHOTGUN_WEAPON:
|
||||||
return new ShotgunWeapon(p->GetWorld(), p);
|
return new ShotgunWeapon4(p->GetWorld(), p);
|
||||||
default:
|
default:
|
||||||
SPInvalidEnum("type", type);
|
SPInvalidEnum("type", type);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
switch(type) {
|
||||||
|
case RIFLE_WEAPON:
|
||||||
|
return new RifleWeapon3(p->GetWorld(), p);
|
||||||
|
case SMG_WEAPON:
|
||||||
|
return new SMGWeapon3(p->GetWorld(), p);
|
||||||
|
case SHOTGUN_WEAPON:
|
||||||
|
return new ShotgunWeapon3(p->GetWorld(), p);
|
||||||
|
default:
|
||||||
|
SPInvalidEnum("type", type);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
namespace spades {
|
namespace spades {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
int protoVersion = 0;
|
||||||
|
|
||||||
|
|
||||||
World::World(){
|
World::World(){
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace spades {
|
namespace spades {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
extern int protoVersion; // TODO: move this somewhere better
|
||||||
class GameMap;
|
class GameMap;
|
||||||
class GameMapWrapper;
|
class GameMapWrapper;
|
||||||
class Player;
|
class Player;
|
||||||
|
@ -32,7 +32,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
FLTK_CFLAGS=`${FLTK_CONFIG} --cxxflags --use-images`
|
FLTK_CFLAGS=`${FLTK_CONFIG} --cxxflags --use-images`
|
||||||
FLTK_LIBS=`${FLTK_CONFIG} --ldstaticflags --use-images`
|
FLTK_LIBS=`${FLTK_CONFIG} --ldflags --use-images`
|
||||||
|
|
||||||
case $host_os in
|
case $host_os in
|
||||||
darwin* )
|
darwin* )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user