mirror of
https://github.com/SWG-Source/src.git
synced 2026-08-01 01:16:03 -04:00
Added SwgGameServer project
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
|
||||
#add_subdirectory(application)
|
||||
add_subdirectory(application)
|
||||
add_subdirectory(library)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
add_subdirectory(SwgGameServer)
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(SwgGameServer)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/public)
|
||||
|
||||
add_subdirectory(src)
|
||||
@@ -0,0 +1,32 @@
|
||||
Using maketable.pl
|
||||
|
||||
This PERL script can generate some of the more boring sections of the database code. To run it,
|
||||
feed in the header files for the object declarations like so:
|
||||
|
||||
./maketable.pl ../src/shared/object/*.h
|
||||
|
||||
It outputs several files. The text of these files should be pasted into sections of the server
|
||||
code. These sections are set off with comments like this:
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// From savepackage.auto
|
||||
// BEGIN AUTO_GENERATED CODE #############################
|
||||
|
||||
....
|
||||
|
||||
// END AUTO_GENERATED CODE #############################
|
||||
|
||||
The utility putauto.pl will paste in any autogenerated files. Run it like this:
|
||||
|
||||
./putauto.pl <file(s) to process, e.g. ../src/shared/database/Schema.h>
|
||||
|
||||
The script putall will run putauto.pl on all the necessary files, except for create.ddl
|
||||
|
||||
These are the output files:
|
||||
sql.auto (sql for creating tables, goes into create.ddl)
|
||||
Schema.h.auto (goes into Schema.h)
|
||||
ObjectQueries.cpp.auto (etc.)
|
||||
ObjectQueries.h.auto
|
||||
MakeDBPackage.cpp.auto
|
||||
DatabasePackage.h.auto
|
||||
DatabasePackage.cpp.auto
|
||||
@@ -0,0 +1,3 @@
|
||||
integer BindableLong
|
||||
float BindableDouble
|
||||
char(1) BindableBool
|
||||
@@ -0,0 +1,372 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This auto-gens some of the more boring code for dealing with
|
||||
# database objects. The generated code needs to be cut-and
|
||||
# pasted into the appropriate files. The idea is to save
|
||||
# typing and reduce errors, not to fully automate the system.
|
||||
|
||||
open (TYPEMAP,"typemap.def");
|
||||
while ($_=<TYPEMAP>)
|
||||
{
|
||||
chop;
|
||||
($c,$db,$cast) = split /\t/;
|
||||
$typemap{$c}=$db;
|
||||
if ($cast ne "")
|
||||
{
|
||||
$cast{$c}=1;
|
||||
}
|
||||
}
|
||||
close (TYPEMAP);
|
||||
|
||||
open (BINDMAP,"bindmap.def");
|
||||
while ($_=<BINDMAP>)
|
||||
{
|
||||
chop;
|
||||
($db,$bindable) = split /\t/;
|
||||
$bindablemap{$db}=$bindable;
|
||||
}
|
||||
close (BINDMAP);
|
||||
|
||||
while (<>)
|
||||
{
|
||||
if(/\/\/.*BPM/)
|
||||
{
|
||||
&parseBPM();
|
||||
}
|
||||
}
|
||||
|
||||
open (SQL,">sql.auto");
|
||||
open (SCHEMA,">Schema.h.auto");
|
||||
open (QUERY,">ObjectQueries.cpp.auto");
|
||||
open (QUERYH,">ObjectQueries.h.auto");
|
||||
open (MAKEPACKAGE,">MakeDBPackage.cpp.auto");
|
||||
open (PACKAGEH,">DatabasePackage.h.auto");
|
||||
open (SAVEPACKAGE,">DatabasePackage.cpp.auto");
|
||||
|
||||
# Print out the tables
|
||||
foreach $tablename (sort keys %columns)
|
||||
{
|
||||
# build a list of columns, including those from inherited classes
|
||||
$col="";
|
||||
for ($dep=$depend{$tablename}; $dep ne ""; $dep=$depend{$dep})
|
||||
{
|
||||
$col=$col.$columns{$dep};
|
||||
}
|
||||
|
||||
$col=$col.$columns{$tablename};
|
||||
|
||||
########################################################
|
||||
# print out the table creation script
|
||||
########################################################
|
||||
|
||||
print SQL "create table ".&dbIzeName($tablename)."s\n(\n";
|
||||
@tabledef = ();
|
||||
push (@tabledef, "\tobject_id integer");
|
||||
foreach $colrec (split /\|/,$col)
|
||||
{
|
||||
($name,$type) = split / /,$colrec;
|
||||
if ($typemap{$type} eq "")
|
||||
{
|
||||
# push (@tabledef, "--\t".$name." ".$type)
|
||||
}
|
||||
else
|
||||
{
|
||||
push (@tabledef, "\t".&dbIzeName($name)." ".$typemap{$type});
|
||||
}
|
||||
}
|
||||
|
||||
print SQL join (",\n",@tabledef);
|
||||
print SQL "\n);\n\n";
|
||||
|
||||
########################################################
|
||||
# print out the row object
|
||||
########################################################
|
||||
|
||||
print SCHEMA "struct ".$tablename."Row : public DB::Row\n{\n";
|
||||
print SCHEMA "\tDB::BindableLong object_id;\n";
|
||||
foreach $colrec (split /\|/,$col)
|
||||
{
|
||||
($name,$type) = split / /,$colrec;
|
||||
if ($typemap{$type} ne "")
|
||||
{
|
||||
print SCHEMA "\tDB::".$bindablemap{$typemap{$type}}." ".&dbIzeName($name).";\n";
|
||||
}
|
||||
}
|
||||
print SCHEMA "};\n\n";
|
||||
|
||||
########################################################
|
||||
#print out the query class declaration
|
||||
########################################################
|
||||
|
||||
print QUERYH "class ".$tablename."Query : public DB::ModeQuery\n{\n";
|
||||
print QUERYH "\t".$tablename."Query(const ".$tablename."Query&); // disable\n";
|
||||
print QUERYH "\t".$tablename."Query& operator=(const ".$tablename."Query&); // disable\n";
|
||||
print QUERYH "public:\n";
|
||||
print QUERYH "\t".$tablename."Query() {}\n\n";
|
||||
print QUERYH "\tbool bind();\n";
|
||||
print QUERYH "\tchar *getSQL();\n";
|
||||
print QUERYH "};\n\n";
|
||||
|
||||
########################################################
|
||||
#print out the bind function
|
||||
########################################################
|
||||
|
||||
$count=1;
|
||||
$bind="bool ".$tablename."Query::bind()\n{\n";
|
||||
$bind=$bind."\t".$tablename."Row *myData=dynamic_cast<".$tablename."Row*>(data);\n";
|
||||
$bind=$bind."\tswitch (mode)\n\t{\n";
|
||||
|
||||
$bindObjId="\t\t\tif (!myData->object_id.bindParameter(1,this)) return false;\n";
|
||||
|
||||
$updSection="\t\tcase mode_UPDATE:\n\t\tcase mode_INSERT:\n";
|
||||
$selSection="\t\tcase mode_SELECT:\n".$bindObjId."\n";
|
||||
foreach $colrec (split /\|/,$col)
|
||||
{
|
||||
($name,$type) = split / /,$colrec;
|
||||
if ($typemap{$type} ne "")
|
||||
{
|
||||
$updSection=$updSection."\t\t\tif (!myData->".&dbIzeName($name).".bindParameter(".$count.",this)) return false;\n";
|
||||
$selSection=$selSection."\t\t\tif (!myData->".&dbIzeName($name).".bindCol(".$count.",this)) return false;\n";
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$updSection=$updSection."\n\t\t\tif (!myData->object_id.bindParameter($count,this)) return false;\n";
|
||||
|
||||
|
||||
$bind=$bind.$updSection."\t\t\tbreak;\n\n".$selSection."\t\t\tbreak;\n\n";
|
||||
$bind=$bind."\t\tcase mode_DELETE:\n".$bindObjId."\t\t\tbreak;\n\n";
|
||||
$bind=$bind."\t\tdefault:\n\t\t\tDEBUG_FATAL(true,(\"Bad query mode.\"));\n";
|
||||
$bind=$bind."\t}\n\treturn true;\n}\n\n";
|
||||
print QUERY $bind; #fix object_id -- should be last for update,insert
|
||||
|
||||
|
||||
########################################################
|
||||
# Print out the SQL
|
||||
########################################################
|
||||
|
||||
@columnNames=();
|
||||
foreach $colrec (split /\|/,$col)
|
||||
{
|
||||
($name,$type) = split / /,$colrec;
|
||||
if ($typemap{$type} ne "")
|
||||
{
|
||||
push @columnNames,&dbIzeName($name);
|
||||
}
|
||||
}
|
||||
|
||||
print QUERY "char *".$tablename."Query::getSQL()\n{\n\tswitch(mode)\n\t{\n";
|
||||
print QUERY "\t\tcase mode_UPDATE:\n";
|
||||
print QUERY "\t\t\treturn (\"update ".&dbIzeName($tablename)."s set ";
|
||||
print QUERY join("=?, ",@columnNames)."=? where object_id=?\");\n";
|
||||
|
||||
print QUERY "\t\tcase mode_INSERT:\n";
|
||||
print QUERY "\t\t\treturn (\"insert into ".&dbIzeName($tablename)."s (";
|
||||
print QUERY join(", ",@columnNames).", object_id) values (";
|
||||
foreach $temp (@columnNames) { print QUERY "?, ";}
|
||||
print QUERY "?)\");\n";
|
||||
|
||||
print QUERY "\t\tcase mode_DELETE:\n";
|
||||
print QUERY "\t\t\treturn (\"delete from ".&dbIzeName($tablename)."s where object_id=?\");\n";
|
||||
|
||||
print QUERY "\t\tcase mode_SELECT:\n";
|
||||
print QUERY "\t\t\treturn (\"select ";
|
||||
print QUERY join(", ",@columnNames);
|
||||
print QUERY " from ".&dbIzeName($tablename)."s where object_id=?\");\n";
|
||||
|
||||
print QUERY "\t\tdefault:\n";
|
||||
print QUERY "\t\t\tDEBUG_FATAL(true,(\"Bad query mode.\"));\n";
|
||||
|
||||
print QUERY "\t}\n\treturn 0; // this is unreachable but here to avoid compiler warning\n}\n\n";
|
||||
|
||||
########################################################
|
||||
# Print out the Package declaration
|
||||
########################################################
|
||||
|
||||
print PACKAGEH "class ".$tablename."Package : public ServerObjectPackage\n{\n";
|
||||
print PACKAGEH "public:\n";
|
||||
print PACKAGEH "\t".$tablename."Package() {}\n\n";
|
||||
|
||||
print PACKAGEH "\tvirtual void finishLoad(Snapshot *snap, DB::Session *ses);\n";
|
||||
print PACKAGEH "\tvirtual void save(Snapshot *snap, DB::Session *ses);\n";
|
||||
|
||||
print PACKAGEH "private:\n";
|
||||
print PACKAGEH "\t".$tablename."Package(const ".$tablename."Package&); //disable\n";
|
||||
print PACKAGEH "\t".$tablename."Package& operator=(const ".$tablename."Package&); // disable\n\n";
|
||||
print PACKAGEH "\tDBSchema::".$tablename."Row data;\n\n";
|
||||
|
||||
print PACKAGEH "\tfriend class ::".$tablename.";\n};\n\n";
|
||||
|
||||
########################################################
|
||||
# Print out the CreatePacakge functions
|
||||
########################################################
|
||||
|
||||
print MAKEPACKAGE "DBPackage::ServerObjectPackage* ".$tablename."::MakeDBPackage(void) const\n{\n";
|
||||
print MAKEPACKAGE "\tDBPackage::".$tablename."Package *buffer=new DBPackage::".$tablename."Package;\n";
|
||||
print MAKEPACKAGE "\tbuffer->status=databaseStatus;\n";
|
||||
print MAKEPACKAGE "\tMakeDBPackage(buffer);\n";
|
||||
print MAKEPACKAGE "\treturn buffer;\n}\n\n";
|
||||
|
||||
print MAKEPACKAGE "void ".$tablename."::MakeDBPackage(DBPackage::ServerObjectPackage *buffer) const\n{\n";
|
||||
print MAKEPACKAGE "\tDBPackage::".$tablename."Package *myBuffer=dynamic_cast<DBPackage::".$tablename."Package*>(buffer);\n";
|
||||
print MAKEPACKAGE "\tNOT_NULL(myBuffer);\n\n";
|
||||
print MAKEPACKAGE "\tmyBuffer->data.object_id=getNetworkId();\n";
|
||||
foreach $colrec (split /\|/,$col)
|
||||
{
|
||||
($name,$type) = split / /,$colrec;
|
||||
if ($typemap{$type} ne "")
|
||||
{
|
||||
print MAKEPACKAGE "\tmyBuffer->data.".&dbIzeName($name)."=".&getterName($name)."();\n";
|
||||
}
|
||||
}
|
||||
print MAKEPACKAGE "\n\tNetworkObject::MakeDBPackage(buffer);\n}\n\n";
|
||||
|
||||
########################################################
|
||||
# Print out the LoadFromPackage functions
|
||||
########################################################
|
||||
|
||||
#constructor -- going away
|
||||
# if ($depend{$tablename} eq "")
|
||||
# {
|
||||
# print MAKEPACKAGE $tablename."::".$tablename."(DBPackage::ServerObjectPackage *buffer) : NetworkObject(buffer)\n";
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# print MAKEPACKAGE $tablename."::".$tablename."(DBPackage::ServerObjectPackage *buffer) : ".$depend{$tablename}."(buffer)\n";
|
||||
# }
|
||||
|
||||
# print MAKEPACKAGE "{\n";
|
||||
# print MAKEPACKAGE "\tDBPackage::".$tablename."Package *myPackage=dynamic_cast<DBPackage::".$tablename."Package*>(buffer);\n";
|
||||
# print MAKEPACKAGE "\tDEBUG_FATAL(myPackage==0,(\"Attempt to create a ".$tablename." from something that isn't a ".$tablename."Package\"));\n\n";
|
||||
|
||||
# foreach $colrec (split /\|/,$col)
|
||||
# {
|
||||
# ($name,$type) = split / /,$colrec;
|
||||
# if ($typemap{$type} ne "")
|
||||
# {
|
||||
# if ($cast{$type} ne "")
|
||||
# {
|
||||
# print MAKEPACKAGE "\t".&setterName($name)."(static_cast<".$type.">(myPackage->data.".&dbIzeName($name).".getValue()));\n";
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# print MAKEPACKAGE "\t".&setterName($name)."(myPackage->data.".&dbIzeName($name).".getValue());\n";
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# print MAKEPACKAGE "}\n\n";
|
||||
|
||||
#loadFromDBPackage -- keep
|
||||
print MAKEPACKAGE "void ".$tablename."::loadFromDBPackage(DBPackage::ServerObjectPackage *buffer)\n";
|
||||
print MAKEPACKAGE "{\n";
|
||||
print MAKEPACKAGE "\tDBPackage::".$tablename."Package *myPackage=dynamic_cast<DBPackage::".$tablename."Package*>(buffer);\n";
|
||||
print MAKEPACKAGE "\tDEBUG_FATAL(myPackage==0,(\"Attempt to create object %i, a ".$tablename." from something that isn't a ".$tablename."Package. May indicate that the object's type_id doesn't match its template.\",buffer->getObjectId()));\n\n";
|
||||
print MAKEPACKAGE "\tNetworkObject::loadFromDBPackage(buffer);\n\n";
|
||||
foreach $colrec (split /\|/,$col)
|
||||
{
|
||||
($name,$type) = split / /,$colrec;
|
||||
if ($typemap{$type} ne "")
|
||||
{
|
||||
if ($cast{$type} ne "")
|
||||
{
|
||||
print MAKEPACKAGE "\t".&setterName($name)."(static_cast<".$type.">(myPackage->data.".&dbIzeName($name).".getValue()));\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print MAKEPACKAGE "\t".&setterName($name)."(myPackage->data.".&dbIzeName($name).".getValue());\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
print MAKEPACKAGE "}\n\n";
|
||||
|
||||
########################################################
|
||||
# Print out the save & load package functions
|
||||
########################################################
|
||||
|
||||
print SAVEPACKAGE "void DBPackage::".$tablename."Package::finishLoad(Snapshot *snap, DB::Session *ses)\n";
|
||||
print SAVEPACKAGE "{\n";
|
||||
print SAVEPACKAGE "\tUNREF(ses);\n";
|
||||
print SAVEPACKAGE "\tUNREF(snap);\n\n";
|
||||
|
||||
print SAVEPACKAGE "\tDBQuery::".$tablename."Query q;\n";
|
||||
print SAVEPACKAGE "\tq.selectMode();\n";
|
||||
print SAVEPACKAGE "\tdata.object_id=baseData.object_id;\n";
|
||||
print SAVEPACKAGE "\tq.setData(&data);\n\n";
|
||||
|
||||
print SAVEPACKAGE "\tses->exec(&q);\n";
|
||||
print SAVEPACKAGE "\tif (!q.fetch())\n";
|
||||
print SAVEPACKAGE "\t{\n";
|
||||
print SAVEPACKAGE "\t\tFATAL (true,(\"Unable to retrive additional data needed by object %i\",baseData.object_id.getValue()));\n";
|
||||
print SAVEPACKAGE "\t}\n\n";
|
||||
|
||||
print SAVEPACKAGE "\tq.done();\n";
|
||||
print SAVEPACKAGE "}\n\n";
|
||||
|
||||
print SAVEPACKAGE "void DBPackage::".$tablename."Package::save(Snapshot *snap, DB::Session *ses)\n";
|
||||
print SAVEPACKAGE "{\n";
|
||||
print SAVEPACKAGE "\tDBQuery::".$tablename."Query q;\n\n";
|
||||
|
||||
print SAVEPACKAGE "\tswitch(status)\n";
|
||||
print SAVEPACKAGE "\t{\n";
|
||||
print SAVEPACKAGE "\t\tcase ::NetworkObject::NEW_OBJECT:\n";
|
||||
print SAVEPACKAGE "\t\t\tq.insertMode();\n";
|
||||
print SAVEPACKAGE "\t\t\tbreak;\n\n";
|
||||
|
||||
print SAVEPACKAGE "\t\tcase ::NetworkObject::CHANGED:\n";
|
||||
print SAVEPACKAGE "\t\t\tq.updateMode();\n";
|
||||
print SAVEPACKAGE "\t\t\tbreak;\n\n";
|
||||
|
||||
print SAVEPACKAGE "\t\tdefault:\n";
|
||||
print SAVEPACKAGE "\t\t\tFATAL(true,(\"Unsupported database status.\"));\n";
|
||||
print SAVEPACKAGE "\t}\n\n";
|
||||
|
||||
print SAVEPACKAGE "\tq.setData(&data);\n";
|
||||
print SAVEPACKAGE "\tses->exec(&q);\n";
|
||||
print SAVEPACKAGE "\tq.done();\n";
|
||||
|
||||
print SAVEPACKAGE "\tServerObjectPackage::save(snap,ses);\n";
|
||||
print SAVEPACKAGE "}\n\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub parseBPM
|
||||
{
|
||||
$_ =~ /BPM\s*(\w*)/;
|
||||
$tablename=$1;
|
||||
if ($_ =~ /BPM\s*\w+\s*\:\s*(\w+)/)
|
||||
{
|
||||
$depend{$tablename} = $1;
|
||||
}
|
||||
$_=<>;
|
||||
while (!($_ =~ /\/\/.*EPM/))
|
||||
{
|
||||
if ($_ =~ /([^\s]+)\s+([^\s]+)\;/)
|
||||
{
|
||||
($type,$name)=($1,$2);
|
||||
$columns{$tablename}=$columns{$tablename}.$name." ".$type."|";
|
||||
}
|
||||
$_=<>;
|
||||
}
|
||||
}
|
||||
|
||||
sub dbIzeName
|
||||
{
|
||||
my($name)=@_;
|
||||
$name =~ s/([a-z])([A-Z])/$1_$2/g;
|
||||
$name =~ tr/[A-Z]/[a-z]/;
|
||||
return $name;
|
||||
}
|
||||
|
||||
sub getterName
|
||||
{
|
||||
my($name)=@_;
|
||||
$name = "get".ucfirst ($name);
|
||||
return $name;
|
||||
}
|
||||
|
||||
sub setterName
|
||||
{
|
||||
my($name)=@_;
|
||||
$name = "set".ucfirst ($name);
|
||||
return $name;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
./maketable.pl ../src/shared/object/*.h
|
||||
|
||||
p4 open ../src/shared/database/Schema.h ../src/shared/database/ObjectQueries.cpp ../src/shared/database/ObjectQueries.h ../src/shared/database/MakeDBPackage.cpp ../src/shared/database/DatabasePackage.h ../src/shared/database/DatabasePackage.cpp ../../database/schema/create.ddl
|
||||
|
||||
./putauto.pl ../src/shared/database/Schema.h ../src/shared/database/ObjectQueries.cpp ../src/shared/database/ObjectQueries.h ../src/shared/database/MakeDBPackage.cpp ../src/shared/database/DatabasePackage.h ../src/shared/database/DatabasePackage.cpp ../../database/schema/create.ddl
|
||||
|
||||
p4 revert -a ../src/shared/database/Schema.h ../src/shared/database/ObjectQueries.cpp ../src/shared/database/ObjectQueries.h ../src/shared/database/MakeDBPackage.cpp ../src/shared/database/DatabasePackage.h ../src/shared/database/DatabasePackage.cpp ../../database/schema/create.ddl
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
@files=@ARGV;
|
||||
|
||||
foreach $file (@files)
|
||||
{
|
||||
print "Working on $file\n";
|
||||
|
||||
open (INFILE,$file);
|
||||
open (OUTFILE,">".$file.".tmp");
|
||||
while (<INFILE>)
|
||||
{
|
||||
print OUTFILE $_;
|
||||
if ((/\/\/\s*From\s+([^\s]+)/) ||
|
||||
(/--\s*From\s+([^\s]+)/))
|
||||
{
|
||||
$from=$1;
|
||||
}
|
||||
if ((/\/\/ BEGIN AUTO_GENERATED CODE\s*\#/) ||
|
||||
(/-- BEGIN AUTO_GENERATED CODE/))
|
||||
{
|
||||
&insertFile($from);
|
||||
while (!(/\/\/ END AUTO_GENERATED CODE\s*\#/) &&
|
||||
!(/-- END AUTO_GENERATED CODE/))
|
||||
{
|
||||
$_=<INFILE>;
|
||||
}
|
||||
print OUTFILE $_;
|
||||
}
|
||||
}
|
||||
close (OUTFILE);
|
||||
close(INFILE);
|
||||
|
||||
$rc=system("diff --brief $file.tmp $file");
|
||||
if ($rc!=0)
|
||||
{
|
||||
system ("cp $file.tmp $file");
|
||||
}
|
||||
system("rm $file.tmp");
|
||||
}
|
||||
|
||||
sub insertFile
|
||||
{
|
||||
print OUTFILE "\n";
|
||||
|
||||
my($filename)=@_;
|
||||
open (INSFILE,$filename);
|
||||
while (<INSFILE>)
|
||||
{
|
||||
print OUTFILE $_;
|
||||
}
|
||||
close INSFILE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
int integer
|
||||
bool char(1)
|
||||
NetworkId integer
|
||||
Gender integer cast
|
||||
ArmorEffectiveness integer
|
||||
real float cast
|
||||
StringId integer
|
||||
InstallationType integer cast
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/core/CSHandler.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/combat/CombatEngine.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/combat/ConfigCombatEngine.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/console/ConsoleCommandParserCombatEngine.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/console/ConsoleCommandParserCombatEngineQueue.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/core/FirstSwgGameServer.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/controller/JediManagerController.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/JediManagerObject.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/objectTemplate/ServerJediManagerObjectTemplate.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/SwgCreatureObject.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/core/SwgGameServer.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/controller/SwgPlayerCreatureController.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/object/SwgPlayerObject.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/objectTemplate/SwgServerCreatureObjectTemplate.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/objectTemplate/SwgServerPlayerObjectTemplate.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/core/SwgServerUniverse.h"
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "../../src/shared/snapshot/WorldSnapshotParser.h"
|
||||
@@ -0,0 +1,110 @@
|
||||
|
||||
set(SHARED_SOURCES
|
||||
shared/combat/combat.def
|
||||
shared/combat/CombatEngine.cpp
|
||||
shared/combat/CombatEngine.h
|
||||
shared/combat/ConfigCombatEngine.cpp
|
||||
shared/combat/ConfigCombatEngine.h
|
||||
|
||||
shared/console/ConsoleCommandParserCombatEngine.cpp
|
||||
shared/console/ConsoleCommandParserCombatEngine.h
|
||||
shared/console/ConsoleCommandParserCombatEngineQueue.cpp
|
||||
shared/console/ConsoleCommandParserCombatEngineQueue.h
|
||||
|
||||
shared/controller/JediManagerController.cpp
|
||||
shared/controller/JediManagerController.h
|
||||
shared/controller/SwgPlayerCreatureController.cpp
|
||||
shared/controller/SwgPlayerCreatureController.h
|
||||
|
||||
shared/core/CSHandler.cpp
|
||||
shared/core/CSHandler.h
|
||||
shared/core/SwgGameServer.cpp
|
||||
shared/core/SwgGameServer.h
|
||||
shared/core/SwgServerUniverse.cpp
|
||||
shared/core/SwgServerUniverse.h
|
||||
|
||||
shared/lint/ServerObjectLint.cpp
|
||||
shared/lint/ServerObjectLint.h
|
||||
|
||||
shared/object/JediManagerObject.cpp
|
||||
shared/object/JediManagerObject.h
|
||||
shared/object/SwgCreatureObject.cpp
|
||||
shared/object/SwgCreatureObject.h
|
||||
shared/object/SwgPlayerObject.cpp
|
||||
shared/object/SwgPlayerObject.h
|
||||
|
||||
shared/objectTemplate/ServerJediManagerObjectTemplate.cpp
|
||||
shared/objectTemplate/ServerJediManagerObjectTemplate.h
|
||||
shared/objectTemplate/SwgServerCreatureObjectTemplate.cpp
|
||||
shared/objectTemplate/SwgServerCreatureObjectTemplate.h
|
||||
shared/objectTemplate/SwgServerPlayerObjectTemplate.cpp
|
||||
shared/objectTemplate/SwgServerPlayerObjectTemplate.h
|
||||
|
||||
shared/snapshot/WorldSnapshotParser.cpp
|
||||
shared/snapshot/WorldSnapshotParser.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(PLATFORM_SOURCES
|
||||
win32/FirstSwgGameServer.cpp
|
||||
win32/WinMain.cpp
|
||||
)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/win32)
|
||||
else()
|
||||
set(PLATFORM_SOURCES
|
||||
linux/main.cpp
|
||||
)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/linux)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shared/combat
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shared/core
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shared/lint
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCollision/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCommandParser/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedImage/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedPathfinding/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRegex/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSkillSystem/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedTerrain/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverGame/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverNetworkMessages/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverPathfinding/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverScript/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverUtility/include/public
|
||||
${SWG_GAME_SOURCE_DIR}/shared/library/swgSharedNetworkMessages/include/public
|
||||
${SWG_GAME_SOURCE_DIR}/shared/library/swgSharedUtility/include/public
|
||||
${SWG_GAME_SOURCE_DIR}/server/library/swgServerNetworkMessages/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/fileInterface/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localization/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localizationArchive/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/singleton/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public
|
||||
${Boost_INCLUDE_DIR}
|
||||
${JNI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
add_executable(SwgGameServer
|
||||
${SHARED_SOURCES}
|
||||
${PLATFORM_SOURCES}
|
||||
)
|
||||
@@ -0,0 +1,141 @@
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "serverGame/GameServer.h"
|
||||
|
||||
#include "LocalizationManager.h"
|
||||
#include "serverGame/SetupServerGame.h"
|
||||
#include "serverPathfinding/SetupServerPathfinding.h"
|
||||
#include "serverScript/SetupScript.h"
|
||||
#include "serverUtility/SetupServerUtility.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/ExitChain.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedGame/SetupSharedGame.h"
|
||||
#include "sharedImage/SetupSharedImage.h"
|
||||
#include "sharedLog/LogManager.h"
|
||||
#include "sharedLog/SetupSharedLog.h"
|
||||
#include "sharedMath/SetupSharedMath.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedObject/SetupSharedObject.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedRegex/SetupSharedRegex.h"
|
||||
#include "sharedTerrain/SetupSharedTerrain.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "sharedUtility/SetupSharedUtility.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "SwgGameServer/SwgGameServer.h"
|
||||
#include "SwgGameServer/WorldSnapshotParser.h"
|
||||
#include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h"
|
||||
#include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h"
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
setupFoundationData.lpCmdLine = ConvertCommandLine(argc,argv);
|
||||
setupFoundationData.runInBackground = true;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupServerUtility::install();
|
||||
|
||||
SetupSharedRegex::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedMath::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
|
||||
SetupSharedUtility::Data setupUtilityData;
|
||||
SetupSharedUtility::setupGameData (setupUtilityData);
|
||||
SetupSharedUtility::install (setupUtilityData);
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
SetupSwgSharedNetworkMessages::install();
|
||||
SetupSwgServerNetworkMessages::install();
|
||||
|
||||
SetupSharedRandom::install(time(0));//lint !e732
|
||||
{
|
||||
SetupSharedObject::Data data;
|
||||
SetupSharedObject::setupDefaultGameData(data);
|
||||
// we want the SlotIdManager initialized, but we don't need the associated hardpoint names on the server.
|
||||
SetupSharedObject::addSlotIdManagerData(data, false);
|
||||
// we want movement table information on this server
|
||||
SetupSharedObject::addMovementTableData(data);
|
||||
// we want CustomizationData support on this server.
|
||||
SetupSharedObject::addCustomizationSupportData(data);
|
||||
// we want POB ejection point override support.
|
||||
SetupSharedObject::addPobEjectionTransformData(data);
|
||||
// objects should not automatically alter their children and contents
|
||||
data.objectsAlterChildrenAndContents = false;
|
||||
SetupSharedObject::install(data);
|
||||
}
|
||||
|
||||
char tmp[92];
|
||||
sprintf(tmp, "SwgGameServer:%d", Os::getProcessId());
|
||||
SetupSharedLog::install(tmp);
|
||||
|
||||
TreeFile::addSearchAbsolute(0);
|
||||
TreeFile::addSearchPath(".",0);
|
||||
|
||||
SetupSharedImage::Data setupImageData;
|
||||
SetupSharedImage::setupDefaultData (setupImageData);
|
||||
SetupSharedImage::install (setupImageData);
|
||||
|
||||
SetupSharedGame::Data setupSharedGameData;
|
||||
setupSharedGameData.setUseMountValidScaleRangeTable(true);
|
||||
setupSharedGameData.setUseClientCombatManagerSupport(true);
|
||||
SetupSharedGame::install (setupSharedGameData);
|
||||
|
||||
SetupSharedTerrain::Data setupSharedTerrainData;
|
||||
SetupSharedTerrain::setupGameData (setupSharedTerrainData);
|
||||
SetupSharedTerrain::install (setupSharedTerrainData);
|
||||
|
||||
SetupScript::Data setupScriptData;
|
||||
SetupScript::setupDefaultGameData(setupScriptData);
|
||||
SetupScript::install();
|
||||
|
||||
SetupServerPathfinding::install();
|
||||
|
||||
//-- setup game server
|
||||
SetupServerGame::install();
|
||||
|
||||
NetworkHandler::install();
|
||||
Os::setProgramName("SwgGameServer");
|
||||
SwgGameServer::install();
|
||||
|
||||
#ifdef _DEBUG
|
||||
//-- see if the game server is being run in a mode to parse the database dump to create planetary snapshot files
|
||||
const char* const createWorldSnapshots = ConfigFile::getKeyString("WorldSnapshot", "createWorldSnapshots", 0);
|
||||
if (createWorldSnapshots)
|
||||
{
|
||||
WorldSnapshotParser::createWorldSnapshots (createWorldSnapshots);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(GameServer::run);
|
||||
}
|
||||
|
||||
NetworkHandler::remove();
|
||||
SetupServerGame::remove();
|
||||
|
||||
SetupSharedLog::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,740 @@
|
||||
//========================================================================
|
||||
//
|
||||
// CombatEngine.cpp
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "CombatEngine.h"
|
||||
|
||||
#include "ConfigCombatEngine.h"
|
||||
#include "serverGame/Client.h"
|
||||
#include "serverGame/ConfigServerGame.h" //@todo code reorg, need another cfg file
|
||||
#include "serverGame/ConsoleManager.h"
|
||||
#include "serverGame/ContainerInterface.h"
|
||||
#include "serverGame/CreatureController.h"
|
||||
#include "serverGame/CreatureObject.h"
|
||||
#include "serverGame/ServerObject.h"
|
||||
#include "serverGame/ServerWorld.h"
|
||||
#include "serverGame/TangibleObject.h"
|
||||
#include "serverGame/WeaponObject.h"
|
||||
#include "serverScript/GameScriptObject.h"
|
||||
#include "serverScript/ScriptFunctionTable.h"
|
||||
#include "serverScript/ScriptParameters.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/ConstCharCrcLowerString.h"
|
||||
#include "sharedFoundation/GameControllerMessage.h"
|
||||
#include "sharedFoundation/GameControllerMessage.h"
|
||||
#include "sharedFoundation/Misc.h"
|
||||
#include "sharedGame/CommandTable.h"
|
||||
#include "sharedGame/GameObjectTypes.h"
|
||||
#include "sharedGame/SharedObjectTemplate.h"
|
||||
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
|
||||
#include "sharedNetworkMessages/MessageQueueNetworkId.h"
|
||||
#include "sharedTerrain/TerrainObject.h"
|
||||
#include "swgServerNetworkMessages/MessageQueueCombatDamageList.h"
|
||||
#include "swgServerNetworkMessages/MessageQueueDirectDamage.h"
|
||||
#include "swgSharedNetworkMessages/CombatActionCompleteMessage.h"
|
||||
#include "swgSharedNetworkMessages/MessageQueueCombatAction.h"
|
||||
#include "swgSharedNetworkMessages/MessageQueueCombatDamage.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
static const std::string UNSKILLED_COMMAND("unskilled");
|
||||
static const ConstCharCrcLowerString COMBAT_TARGET_COMMAND("combattarget");
|
||||
static const ConstCharCrcLowerString AIM_COMMAND("aim");
|
||||
static const ConstCharCrcLowerString DEFAULT_ATTACK_COMMAND("defaultattack");
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// static class variables
|
||||
|
||||
uint16 CombatEngine::ms_nextActionId = 0;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// class functions
|
||||
|
||||
/**
|
||||
* Initializes the combat engine.
|
||||
*/
|
||||
void CombatEngine::install(void)
|
||||
{
|
||||
ConfigCombatEngine::install();
|
||||
|
||||
// set up command queue combat functions
|
||||
CommandTable::addCppFunction("aim", aim);
|
||||
|
||||
ExitChain::add(CombatEngine::remove, "CombatEngine::remove");
|
||||
} // CombatEngine::install
|
||||
|
||||
/**
|
||||
* Cleans up the combat engine.
|
||||
*/
|
||||
void CombatEngine::remove(void)
|
||||
{
|
||||
ConfigCombatEngine::remove();
|
||||
} // CombatEngine::remove
|
||||
|
||||
/**
|
||||
* Reloads the combat data values from the combat config file.
|
||||
*
|
||||
* @return true on success, false on fail
|
||||
*/
|
||||
bool CombatEngine::reloadCombatData(void)
|
||||
{
|
||||
// @todo: can we synchronize this between servers?
|
||||
ConfigCombatEngine::remove();
|
||||
ConfigCombatEngine::install();
|
||||
return true;
|
||||
} // CombatEngine::reloadCombatData
|
||||
|
||||
/**
|
||||
* Adds an aim to an attacker's next attack.
|
||||
*
|
||||
* @param actor the attacker
|
||||
*/
|
||||
void CombatEngine::aim(const Command &, const NetworkId & actor, const NetworkId &, const Unicode::String &)
|
||||
{
|
||||
CachedNetworkId attackerId(actor);
|
||||
TangibleObject * attacker = dynamic_cast<TangibleObject *>(attackerId.getObject());
|
||||
|
||||
if (attacker != NULL)
|
||||
{
|
||||
attacker->addAim();
|
||||
}
|
||||
} // CombatEngine::aim
|
||||
|
||||
/**
|
||||
* Adds a target action to the end of an object's action queue.
|
||||
*
|
||||
* @param attacker the object attacking
|
||||
* @param targets who is being targeted
|
||||
*
|
||||
* @return true on success, false on fail
|
||||
*/
|
||||
bool CombatEngine::addTargetAction(TangibleObject & attacker,
|
||||
const CombatEngineData::TargetIdList & targets)
|
||||
{
|
||||
// @todo: support tangible attacks
|
||||
CreatureObject * const creatureAttacker = attacker.asCreatureObject ();
|
||||
if (creatureAttacker == NULL)
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("Tangible attackers not supported yet"));
|
||||
return false;
|
||||
}
|
||||
|
||||
creatureAttacker->commandQueueEnqueue(CommandTable::getCommand(
|
||||
COMBAT_TARGET_COMMAND.getCrc()), targets[0], Unicode::String());
|
||||
return true;
|
||||
} // CombatEngine::addTargetAction
|
||||
|
||||
/**
|
||||
* Adds an attack action to the end of an object's action queue.
|
||||
*
|
||||
* @param attacker the object attacking
|
||||
* @param weapon the weapon being used (0 = attacker's primary weapon)
|
||||
* @param weaponMode the mode of the weapon being used (0 = primary, -1 = current mode)
|
||||
*
|
||||
* @return true on success, false on fail
|
||||
*/
|
||||
bool CombatEngine::addAttackAction(TangibleObject & attacker,
|
||||
const NetworkId & weapon, int weaponMode)
|
||||
{
|
||||
// @todo: support tangible attacks
|
||||
CreatureObject * const creatureAttacker = attacker.asCreatureObject ();
|
||||
if (creatureAttacker == NULL)
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("Tangible attackers not supported yet"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// set up the weapon id and mode into a params string
|
||||
char buffer[64];
|
||||
sprintf(buffer, "%s %d", weapon.getValueString().c_str(), weaponMode);
|
||||
Unicode::String params(Unicode::narrowToWide(buffer));
|
||||
|
||||
creatureAttacker->commandQueueEnqueue(CommandTable::getCommand(
|
||||
DEFAULT_ATTACK_COMMAND.getCrc()), NetworkId::cms_invalid, params);
|
||||
return true;
|
||||
} // CombatEngine::addAttackAction
|
||||
|
||||
/**
|
||||
* Adds an aim action to the end of an object's action queue.
|
||||
*
|
||||
* @param attacker the object attacking
|
||||
*
|
||||
* @return true on success, false on fail
|
||||
*/
|
||||
bool CombatEngine::addAimAction(TangibleObject & attacker)
|
||||
{
|
||||
if (!attacker.isInCombat())
|
||||
return false;
|
||||
|
||||
// @todo: support tangible attacks
|
||||
CreatureObject * const creatureAttacker = attacker.asCreatureObject ();
|
||||
if (creatureAttacker == NULL)
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("Tangible attackers not supported yet"));
|
||||
return false;
|
||||
}
|
||||
|
||||
creatureAttacker->commandQueueEnqueue(CommandTable::getCommand(
|
||||
AIM_COMMAND.getCrc()), NetworkId::cms_invalid, Unicode::String());
|
||||
return true;
|
||||
} // CombatEngine::addAimAction
|
||||
|
||||
/**
|
||||
* Determines the specific damage to apply to the defender after a successful
|
||||
* attack.
|
||||
*
|
||||
* @param attacker the attacker
|
||||
* @param defender the defender
|
||||
* @param weapon the attacker's weapon
|
||||
* @param damageAmount base damage done
|
||||
* @param hitLocation where the defender was hit
|
||||
*
|
||||
* @return true on success, false if there was an error
|
||||
*/
|
||||
bool CombatEngine::onSuccessfulAttack(const TangibleObject & attacker,
|
||||
TangibleObject & defender, const WeaponObject & weapon, int damageAmount,
|
||||
int hitLocation)
|
||||
{
|
||||
const bool creatureDefender = defender.asCreatureObject() != NULL;
|
||||
const bool isVehicle = GameObjectTypes::isTypeOf (defender.getGameObjectType (), SharedObjectTemplate::GOT_vehicle);
|
||||
|
||||
// if attacking an object, always hit location 0
|
||||
if (!creatureDefender || isVehicle)
|
||||
hitLocation = 0;
|
||||
|
||||
// get the damage profile for the hit location
|
||||
const ConfigCombatEngine::SkeletonAttackMod & skeletonAttackMod =
|
||||
ConfigCombatEngine::getSkeletonAttackMod(static_cast<ServerTangibleObjectTemplate::CombatSkeleton>(defender.getCombatSkeleton()));
|
||||
if (hitLocation < 0 || hitLocation >= static_cast<int>(skeletonAttackMod.attackMods.size()))
|
||||
return false;
|
||||
const ConfigCombatEngineData::BodyAttackMod & hitLocationData =
|
||||
skeletonAttackMod.attackMods[static_cast<size_t>(hitLocation)];
|
||||
|
||||
// put a attribMod structure on the defender's damage list for each type of
|
||||
// damage received
|
||||
DamageList damageList;
|
||||
if (creatureDefender && !isVehicle)
|
||||
{
|
||||
computeCreatureDamage(&hitLocationData, damageAmount, damageList);
|
||||
}
|
||||
else
|
||||
{
|
||||
computeObjectDamage(&hitLocationData, damageAmount, damageList);
|
||||
}
|
||||
if (damageList.empty())
|
||||
return false;
|
||||
|
||||
// determine if the defender was wounded
|
||||
bool isWounded = false;
|
||||
|
||||
if (creatureDefender && !isVehicle)
|
||||
{
|
||||
float woundChance = weapon.getWoundChance() + ConfigCombatEngine::getWoundChance();
|
||||
if (hitLocation)
|
||||
woundChance += hitLocationData.toWoundBonus;
|
||||
if (Random::randomReal(0.0f, 100.0f) <= woundChance)
|
||||
isWounded = true;
|
||||
}
|
||||
|
||||
// apply the damage
|
||||
if (defender.isAuthoritative())
|
||||
{
|
||||
// Ensure the combat data has been initialized
|
||||
defender.createCombatData();
|
||||
|
||||
CombatEngineData::DefenseData & defenseData = defender.getCombatData()->defenseData;
|
||||
defenseData.damage.push_back(CombatEngineData::DamageData());
|
||||
CombatEngineData::DamageData &damageData = defenseData.damage.back();
|
||||
damageData.attackerId = attacker.getNetworkId();
|
||||
damageData.weaponId = weapon.getNetworkId();
|
||||
damageData.damageType = static_cast<CombatEngineData::DamageType>(static_cast<int>(weapon.getDamageType()));
|
||||
damageData.hitLocationIndex = static_cast<uint16>(hitLocation);
|
||||
damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end());
|
||||
damageData.wounded = isWounded;
|
||||
}
|
||||
else
|
||||
{
|
||||
TangibleController * const tangibleController = (defender.getController() != NULL) ? defender.getController()->asTangibleController() : NULL;
|
||||
|
||||
if (tangibleController == NULL)
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("CombatEngine::onSuccessfulAttack non-auth "
|
||||
"defender %s doesn't have a TangibleController!",
|
||||
defender.getNetworkId().getValueString().c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// send the damage info to the authoritative object
|
||||
MessageQueueCombatDamageList * message = new MessageQueueCombatDamageList();
|
||||
NOT_NULL(message);
|
||||
CombatEngineData::DamageData & damageData = message->addDamage();
|
||||
|
||||
damageData.attackerId = attacker.getNetworkId();
|
||||
damageData.weaponId = weapon.getNetworkId();
|
||||
damageData.damageType = static_cast<CombatEngineData::DamageType>(static_cast<int>(weapon.getDamageType()));
|
||||
damageData.hitLocationIndex = static_cast<uint16>(hitLocation);
|
||||
damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end());
|
||||
damageData.wounded = isWounded;
|
||||
|
||||
tangibleController->appendMessage(
|
||||
CM_combatDamageList,
|
||||
0.0f,
|
||||
message,
|
||||
GameControllerMessageFlags::SEND |
|
||||
GameControllerMessageFlags::RELIABLE |
|
||||
GameControllerMessageFlags::DEST_AUTH_SERVER
|
||||
);
|
||||
}//lint !e429 // Custodial pointer 'message' has not been freed or returned // the controller queue will manage freeing the memory
|
||||
|
||||
return true;
|
||||
} // CombatEngine::onSuccessfulAttack
|
||||
|
||||
/**
|
||||
* Determines the specific damage to apply to the defender after a successful
|
||||
* attack.
|
||||
*
|
||||
* @param attacker the attacker
|
||||
* @param defender the defender
|
||||
* @param damageAmount base damage done
|
||||
* @param hitLocation where the defender was hit
|
||||
*
|
||||
* @return true on success, false if there was an error
|
||||
*/
|
||||
bool CombatEngine::onSuccessfulAttack(const TangibleObject & attacker,
|
||||
TangibleObject & defender, int damageAmount,
|
||||
int hitLocation)
|
||||
{
|
||||
const bool creatureDefender = defender.asCreatureObject() != NULL;
|
||||
const bool isVehicle = GameObjectTypes::isTypeOf (defender.getGameObjectType (), SharedObjectTemplate::GOT_vehicle);
|
||||
|
||||
// if attacking an object, always hit location 0
|
||||
if (!creatureDefender || isVehicle)
|
||||
hitLocation = 0;
|
||||
|
||||
// get the damage profile for the hit location
|
||||
const ConfigCombatEngine::SkeletonAttackMod & skeletonAttackMod =
|
||||
ConfigCombatEngine::getSkeletonAttackMod(static_cast<ServerTangibleObjectTemplate::CombatSkeleton>(defender.getCombatSkeleton()));
|
||||
if (hitLocation < 0 || hitLocation >= static_cast<int>(skeletonAttackMod.attackMods.size()))
|
||||
return false;
|
||||
const ConfigCombatEngineData::BodyAttackMod & hitLocationData =
|
||||
skeletonAttackMod.attackMods[static_cast<size_t>(hitLocation)];
|
||||
|
||||
// put a attribMod structure on the defender's damage list for each type of
|
||||
// damage received
|
||||
DamageList damageList;
|
||||
if (creatureDefender && !isVehicle)
|
||||
{
|
||||
computeCreatureDamage(&hitLocationData, damageAmount, damageList);
|
||||
}
|
||||
else
|
||||
{
|
||||
computeObjectDamage(&hitLocationData, damageAmount, damageList);
|
||||
}
|
||||
if (damageList.empty())
|
||||
return false;
|
||||
|
||||
// determine if the defender was wounded
|
||||
bool isWounded = false;
|
||||
|
||||
// apply the damage
|
||||
if (defender.isAuthoritative())
|
||||
{
|
||||
// Ensure the combat data has been initialized
|
||||
defender.createCombatData();
|
||||
|
||||
CombatEngineData::DefenseData & defenseData = defender.getCombatData()->defenseData;
|
||||
defenseData.damage.push_back(CombatEngineData::DamageData());
|
||||
CombatEngineData::DamageData &damageData = defenseData.damage.back();
|
||||
damageData.attackerId = attacker.getNetworkId();
|
||||
damageData.hitLocationIndex = static_cast<uint16>(hitLocation);
|
||||
damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end());
|
||||
damageData.wounded = isWounded;
|
||||
}
|
||||
else
|
||||
{
|
||||
TangibleController * const tangibleController = (defender.getController() != NULL) ? defender.getController()->asTangibleController() : NULL;
|
||||
|
||||
if (tangibleController == NULL)
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("CombatEngine::onSuccessfulAttack non-auth "
|
||||
"defender %s doesn't have a TangibleController!",
|
||||
defender.getNetworkId().getValueString().c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// send the damage info to the authoritative object
|
||||
MessageQueueCombatDamageList * message = new MessageQueueCombatDamageList();
|
||||
NOT_NULL(message);
|
||||
CombatEngineData::DamageData & damageData = message->addDamage();
|
||||
|
||||
damageData.attackerId = attacker.getNetworkId();
|
||||
damageData.hitLocationIndex = static_cast<uint16>(hitLocation);
|
||||
damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end());
|
||||
damageData.wounded = isWounded;
|
||||
|
||||
tangibleController->appendMessage(
|
||||
CM_combatDamageList,
|
||||
0.0f,
|
||||
message,
|
||||
GameControllerMessageFlags::SEND |
|
||||
GameControllerMessageFlags::RELIABLE |
|
||||
GameControllerMessageFlags::DEST_AUTH_SERVER
|
||||
);
|
||||
}//lint !e429 // Custodial pointer 'message' has not been freed or returned // the controller queue will manage freeing the memory
|
||||
|
||||
return true;
|
||||
} // CombatEngine::onSuccessfulAttack
|
||||
|
||||
/**
|
||||
* Damages an object. This damage is immediately applied to the object, outside
|
||||
* the combat loop.
|
||||
*
|
||||
* @param defender the defender
|
||||
* @param weapon the weapon the defender is hit by
|
||||
* @param damageAmount base damage done
|
||||
* @param hitLocation where the defender was hit
|
||||
*
|
||||
* @return true on success, false if there was an error
|
||||
*/
|
||||
bool CombatEngine::damage(TangibleObject & defender, const WeaponObject & weapon,
|
||||
int damageAmount, int hitLocation)
|
||||
{
|
||||
if (defender.isAuthoritative())
|
||||
{
|
||||
CreatureObject * const critter = defender.asCreatureObject();
|
||||
const bool isVehicle = GameObjectTypes::isTypeOf (defender.getGameObjectType (), SharedObjectTemplate::GOT_vehicle);
|
||||
|
||||
// if attacking an object, always hit location 0
|
||||
if (critter == NULL || isVehicle)
|
||||
hitLocation = 0;
|
||||
|
||||
// get the damage profile for the hit location
|
||||
const ConfigCombatEngine::SkeletonAttackMod & skeletonAttackMod =
|
||||
ConfigCombatEngine::getSkeletonAttackMod(static_cast<ServerTangibleObjectTemplate::CombatSkeleton>(defender.getCombatSkeleton()));
|
||||
if (hitLocation < 0 || hitLocation >= static_cast<int>(skeletonAttackMod.attackMods.size()))
|
||||
return false;
|
||||
const ConfigCombatEngineData::BodyAttackMod & hitLocationData =
|
||||
skeletonAttackMod.attackMods[static_cast<size_t>(hitLocation)];
|
||||
|
||||
// put a attribMod structure on the defender's damage list for each type of
|
||||
// damage received
|
||||
DamageList damageList;
|
||||
if (critter != NULL && !isVehicle)
|
||||
{
|
||||
computeCreatureDamage(&hitLocationData, damageAmount, damageList);
|
||||
}
|
||||
else
|
||||
{
|
||||
computeObjectDamage(&hitLocationData, damageAmount, damageList);
|
||||
}
|
||||
if (damageList.empty())
|
||||
return false;
|
||||
|
||||
// determine if the defender was wounded
|
||||
bool isWounded = false;
|
||||
if (critter && !isVehicle)
|
||||
{
|
||||
float woundChance = weapon.getWoundChance() + ConfigCombatEngine::getWoundChance();
|
||||
if (hitLocation)
|
||||
woundChance += hitLocationData.toWoundBonus;
|
||||
if (Random::randomReal(0.0f, 100.0f) <= woundChance)
|
||||
isWounded = true;
|
||||
}
|
||||
|
||||
// apply the damage
|
||||
CombatEngineData::DamageData damageData;
|
||||
damageData.attackerId = NetworkId::cms_invalid;
|
||||
damageData.weaponId = weapon.getNetworkId();
|
||||
damageData.damageType = static_cast<CombatEngineData::DamageType>(static_cast<int>(weapon.getDamageType()));
|
||||
damageData.hitLocationIndex = static_cast<uint16>(hitLocation);
|
||||
damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end());
|
||||
damageData.wounded = isWounded;
|
||||
|
||||
if (critter != NULL || !defender.isDisabled())
|
||||
{
|
||||
// update the object's hit points or attributes for the damage
|
||||
defender.applyDamage(damageData);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} // CombatEngine::damage
|
||||
|
||||
/**
|
||||
* Damages an object. This damage is immediately applied to the object, outside
|
||||
* the combat loop.
|
||||
*
|
||||
* @param defender the object to be damaged
|
||||
* @param damageType the type of damage being done
|
||||
* @param hitLocation the hit location of the damage
|
||||
* @param damage the amount of damage to do
|
||||
*/
|
||||
void CombatEngine::damage(TangibleObject & defender,
|
||||
ServerWeaponObjectTemplate::DamageType damageType, uint16 hitLocation,
|
||||
int damageDone)
|
||||
{
|
||||
if (defender.isAuthoritative())
|
||||
{
|
||||
CreatureObject *critter = defender.asCreatureObject();
|
||||
const bool isVehicle = GameObjectTypes::isTypeOf (defender.getGameObjectType (), SharedObjectTemplate::GOT_vehicle);
|
||||
|
||||
// if attacking an object, always hit location 0
|
||||
if (critter == NULL || isVehicle)
|
||||
hitLocation = 0;
|
||||
|
||||
// get the damage profile for the hit location
|
||||
const ConfigCombatEngine::SkeletonAttackMod & skeletonAttackMod =
|
||||
ConfigCombatEngine::getSkeletonAttackMod(static_cast<ServerTangibleObjectTemplate::CombatSkeleton>(defender.getCombatSkeleton()));
|
||||
if (hitLocation >= static_cast<int>(skeletonAttackMod.attackMods.size()))
|
||||
return;
|
||||
const ConfigCombatEngineData::BodyAttackMod & hitLocationData =
|
||||
skeletonAttackMod.attackMods[static_cast<size_t>(hitLocation)];
|
||||
|
||||
// get the damage
|
||||
DamageList damageList;
|
||||
if (critter && !isVehicle)
|
||||
CombatEngine::computeCreatureDamage(&hitLocationData, damageDone, damageList);
|
||||
else
|
||||
CombatEngine::computeObjectDamage(&hitLocationData, damageDone, damageList);
|
||||
|
||||
if (damageList.empty())
|
||||
return;
|
||||
|
||||
// apply the damage
|
||||
CombatEngineData::DamageData damageData;
|
||||
damageData.attackerId = NetworkId::cms_invalid;
|
||||
damageData.weaponId = NetworkId::cms_invalid;
|
||||
damageData.damageType = static_cast<CombatEngineData::DamageType>(static_cast<int>(damageType));
|
||||
damageData.hitLocationIndex = hitLocation;
|
||||
damageData.damage.insert(damageData.damage.end(), damageList.begin(), damageList.end());
|
||||
|
||||
if (critter != NULL || !defender.isDisabled())
|
||||
{
|
||||
// update the object's hit points or attributes for the damage
|
||||
defender.applyDamage(damageData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
defender.sendControllerMessageToAuthServer(CM_directDamage,
|
||||
new MessageQueueDirectDamage(damageType, hitLocation, damageDone));
|
||||
}
|
||||
} // CombatEngine::damage
|
||||
|
||||
/**
|
||||
* Damages all objects within a given area.
|
||||
*
|
||||
* @param center the center of the area to damage
|
||||
* @param radius the radius of the area to damage
|
||||
* @param damageType the type of damage being done
|
||||
* @param damage the amount of damage to do
|
||||
*/
|
||||
void CombatEngine::damage(const Vector ¢er, float radius,
|
||||
ServerWeaponObjectTemplate::DamageType damageType, int damageDone)
|
||||
{
|
||||
// determine the damage that will occur to creatures and non-creatures
|
||||
DamageList creatureDamageList, objectDamageList;
|
||||
computeCreatureDamage(0, damageDone, creatureDamageList);
|
||||
computeObjectDamage(0, damageDone, objectDamageList);
|
||||
if (creatureDamageList.empty() && objectDamageList.empty())
|
||||
return;
|
||||
|
||||
// get everything in the damage area
|
||||
std::vector<ServerObject *> targetList;
|
||||
ServerWorld::findObjectsInRange(center, radius, targetList);
|
||||
if (targetList.empty())
|
||||
return;
|
||||
|
||||
std::vector<ServerObject *>::iterator iter;
|
||||
for (iter = targetList.begin(); iter != targetList.end(); ++iter)
|
||||
{
|
||||
ServerObject * const obj = *iter;
|
||||
if (!obj)
|
||||
continue;
|
||||
|
||||
TangibleObject * const defender = obj->asTangibleObject ();
|
||||
if (!defender)
|
||||
continue;
|
||||
|
||||
const bool isVehicle = GameObjectTypes::isTypeOf (defender->getGameObjectType (), SharedObjectTemplate::GOT_vehicle);
|
||||
|
||||
// apply the damage
|
||||
{
|
||||
// Ensure the combat data has been initialized
|
||||
defender->createCombatData();
|
||||
|
||||
CombatEngineData::DefenseData & defenseData = defender->getCombatData()->defenseData;
|
||||
defenseData.damage.push_back(CombatEngineData::DamageData());
|
||||
CombatEngineData::DamageData &damageData = defenseData.damage.back();
|
||||
damageData.attackerId = NetworkId::cms_invalid;
|
||||
damageData.weaponId = NetworkId::cms_invalid;
|
||||
damageData.damageType = static_cast<CombatEngineData::DamageType>(static_cast<int>(damageType));
|
||||
damageData.hitLocationIndex = 0;
|
||||
|
||||
if (defender->asCreatureObject () && !isVehicle)
|
||||
{
|
||||
damageData.damage.insert(damageData.damage.end(),
|
||||
creatureDamageList.begin(), creatureDamageList.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
damageData.damage.insert(damageData.damage.end(),
|
||||
objectDamageList.begin(), objectDamageList.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
} // CombatEngine::damage
|
||||
|
||||
/**
|
||||
* Determines how a creature will be damaged.
|
||||
*
|
||||
* @param hitLocation where on the defender the damage occurred
|
||||
* @param damageType the type of damage being done
|
||||
* @param damage the amount of damage to do
|
||||
* @param damageList list to be filled in with attribMods caused by the damage
|
||||
*/
|
||||
void CombatEngine::computeCreatureDamage(
|
||||
const ConfigCombatEngineData::BodyAttackMod *hitLocation,
|
||||
int damageDone,
|
||||
DamageList & damageList)
|
||||
{
|
||||
// put all damage into health
|
||||
damageList.push_back(AttribMod::AttribMod());
|
||||
AttribMod::AttribMod & attribMod = damageList.back();
|
||||
attribMod.tag = 0;
|
||||
attribMod.attrib = Attributes::Health;
|
||||
attribMod.value = -damageDone;
|
||||
attribMod.attack = 0.0f;
|
||||
attribMod.sustain = 0.0f;
|
||||
attribMod.decay = ServerWeaponObjectTemplate::AMDS_pool;
|
||||
attribMod.flags = AttribMod::AMF_directDamage;
|
||||
} // CombatEngine::computeCreatureDamage
|
||||
|
||||
/**
|
||||
* Determines how a non-creature will be damaged.
|
||||
*
|
||||
* @param hitLocation where on the defender the damage occurred
|
||||
* @param damageType the type of damage being done
|
||||
* @param damage the amount of damage to do
|
||||
* @param damageList list to be filled in with attribMods caused by the damage
|
||||
*/
|
||||
void CombatEngine::computeObjectDamage(
|
||||
const ConfigCombatEngineData::BodyAttackMod *hitLocation,
|
||||
int damageDone,
|
||||
DamageList & damageList)
|
||||
{
|
||||
int actualDamage = static_cast<int>(floor(damageDone * 1.0f + 0.5f)); //lint !e747 Significant prototype coercion (arg. no. 1) float to double
|
||||
if (actualDamage == 0)
|
||||
return;
|
||||
|
||||
// create an attribMod structure for damage received
|
||||
if (hitLocation && hitLocation->damageBonus[0] != 0)
|
||||
{
|
||||
if (hitLocation->damageBonus[0] > 0)
|
||||
{
|
||||
actualDamage += static_cast<int>(floor(actualDamage * hitLocation->
|
||||
damageBonus[0] + 0.5f)); //lint !e747 Significant prototype coercion (arg. no. 1) float to double
|
||||
}
|
||||
else
|
||||
{
|
||||
actualDamage += static_cast<int>(ceil(actualDamage * hitLocation->
|
||||
damageBonus[0] - 0.5f)); //lint !e747 Significant prototype coercion (arg. no. 1) float to double
|
||||
}
|
||||
}
|
||||
damageList.push_back(AttribMod::AttribMod());
|
||||
AttribMod::AttribMod & attribMod = damageList.back();
|
||||
attribMod.tag = 0;
|
||||
attribMod.attrib = ServerObjectTemplate::AT_health;
|
||||
attribMod.value = -actualDamage;
|
||||
attribMod.attack = 0.0f;
|
||||
attribMod.sustain = 0.0f;
|
||||
attribMod.decay = ServerWeaponObjectTemplate::AMDS_pool; //lint !e641 Converting enum 'AttribModDecaySpecial' to int
|
||||
attribMod.flags = AttribMod::AMF_directDamage;
|
||||
} // CombatEngine::computeObjectDamage
|
||||
|
||||
/**
|
||||
* Applies combat damage done during execute() to an object. Should be called as
|
||||
* part of the object's alter function.
|
||||
*
|
||||
* @param object the object to damage
|
||||
*/
|
||||
void CombatEngine::alter(TangibleObject & object)
|
||||
{
|
||||
NOT_NULL(object.getController());
|
||||
|
||||
if ( (object.getCombatData() == NULL)
|
||||
|| object.getCombatData()->defenseData.damage.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<CombatEngineData::DamageData> &damageData = object.getCombatData()->defenseData.damage;
|
||||
std::vector<CombatEngineData::DamageData>::iterator iter;
|
||||
|
||||
if (object.isAuthoritative())
|
||||
{
|
||||
// if the object is a creature, get it's attributes
|
||||
Attributes::Value currentAttribs[Attributes::NumberOfAttributes];
|
||||
CreatureObject * const critter = object.asCreatureObject ();
|
||||
if (critter != NULL)
|
||||
{
|
||||
for (int i = 0; i < Attributes::NumberOfAttributes; ++i)
|
||||
currentAttribs[i] = critter->getAttribute(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// @todo: handle damage to objects
|
||||
}
|
||||
// update the object
|
||||
// to guard against the list changing while we are iterating over it,
|
||||
// we will iterate using index rather than iterator
|
||||
for (std::vector<CombatEngineData::DamageData>::size_type i = 0; object.isInCombat() && i < damageData.size(); ++i)
|
||||
{
|
||||
// since armor == hp now, we need to double check that the object
|
||||
// is in combat, since a non-creature could be removed by just
|
||||
// damaging their armor
|
||||
if (object.isInCombat())
|
||||
{
|
||||
// update the object's hit points or attributes for the damage
|
||||
object.applyDamage(damageData[i]);
|
||||
}
|
||||
}
|
||||
}//lint !e550 Symbol 'currentAttribs' (line 2653) not accessed // yes it is
|
||||
else
|
||||
{
|
||||
TangibleController * const tangibleController = object.getController()->asTangibleController();
|
||||
|
||||
if (tangibleController == NULL)
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("CombatEngine::alter non-auth "
|
||||
"object %s doesn't have a TangibleController!",
|
||||
object.getNetworkId().getValueString().c_str()));
|
||||
return;
|
||||
}
|
||||
|
||||
// send the damage info to the authoritative object
|
||||
MessageQueueCombatDamageList * message = new MessageQueueCombatDamageList();
|
||||
NOT_NULL(message);
|
||||
for (iter = damageData.begin(); iter != damageData.end(); ++iter)
|
||||
message->addDamage(*iter);
|
||||
tangibleController->appendMessage(
|
||||
CM_combatDamageList,
|
||||
0.0f,
|
||||
message,
|
||||
GameControllerMessageFlags::SEND |
|
||||
GameControllerMessageFlags::RELIABLE |
|
||||
GameControllerMessageFlags::DEST_AUTH_SERVER
|
||||
);
|
||||
}//lint !e429 Custodial pointer 'message' has not been freed or returned // Controller handles message destruction
|
||||
|
||||
object.clearDamageList();
|
||||
} // CombatEngine::alter
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//========================================================================
|
||||
//
|
||||
// CombatEngine.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
|
||||
#ifndef _INCLUDED_CombatEngine_H
|
||||
#define _INCLUDED_CombatEngine_H
|
||||
|
||||
#include "sharedGame/AttribMod.h"
|
||||
#include "sharedObject/CachedNetworkId.h"
|
||||
#include "serverGame/ServerWeaponObjectTemplate.h"
|
||||
#include "swgSharedUtility/CombatEngineData.h"
|
||||
#include <queue>
|
||||
|
||||
class Command;
|
||||
class CreatureObject;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// class CombatEngine
|
||||
|
||||
class CombatEngine
|
||||
{
|
||||
public:
|
||||
typedef std::vector<AttribMod::AttribMod> DamageList;
|
||||
|
||||
public:
|
||||
|
||||
static void install(void);
|
||||
static void remove(void);
|
||||
|
||||
static bool reloadCombatData(void);
|
||||
|
||||
// command queue hooks
|
||||
static void aim(const Command & command, const NetworkId & actor,
|
||||
const NetworkId & target, const Unicode::String & params);
|
||||
|
||||
// queue actions
|
||||
static bool addTargetAction(TangibleObject & attacker, const CombatEngineData::TargetIdList & targets);
|
||||
static bool addAttackAction(TangibleObject & attacker, const NetworkId & weapon, int weaponMode);
|
||||
static bool addAimAction(TangibleObject & attacker);
|
||||
|
||||
static bool onSuccessfulAttack(const TangibleObject & attacker, TangibleObject & defender, const WeaponObject & weapon, int damage, int hitLocation);
|
||||
static bool onSuccessfulAttack(const TangibleObject & attacker, TangibleObject & defender, int damage, int hitLocation);
|
||||
static bool damage(TangibleObject & defender, const WeaponObject & weapon, int damageAmount, int hitLocation);
|
||||
static void damage(TangibleObject & defender, ServerWeaponObjectTemplate::DamageType damageType, uint16 hitLocation, int damage);
|
||||
static void damage(const Vector ¢er, float radius, ServerWeaponObjectTemplate::DamageType damageType, int damage);
|
||||
static void alter(TangibleObject & object);
|
||||
|
||||
private:
|
||||
|
||||
static uint16 ms_nextActionId; // id to link attack messages with damage messages
|
||||
static uint16 getNextActionId(void);
|
||||
|
||||
static void computeCreatureDamage(
|
||||
const ConfigCombatEngineData::BodyAttackMod *hitLocation,
|
||||
int damage, DamageList & damageList);
|
||||
static void computeObjectDamage(
|
||||
const ConfigCombatEngineData::BodyAttackMod *hitLocation,
|
||||
int damage, DamageList & damageList);
|
||||
};
|
||||
|
||||
|
||||
inline uint16 CombatEngine::getNextActionId(void)
|
||||
{
|
||||
return ++ms_nextActionId;
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_CombatEngine_H
|
||||
@@ -0,0 +1,279 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ConfigCombatEngine.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "ConfigCombatEngine.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/CrcLowerString.h"
|
||||
#include "swgSharedUtility/CombatEngineData.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "combat.def"
|
||||
|
||||
|
||||
#define KEY_INT(a,b) (m_data.a = ConfigFile::getKeyInt("CombatEngine", #a, b))
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// local statics
|
||||
|
||||
namespace ConfigCombatEngineNameSpace
|
||||
{
|
||||
typedef std::map<CrcLowerString, int> BoneMap;
|
||||
BoneMap ms_boneMap;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
using namespace ConfigCombatEngineNameSpace;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// static member variables
|
||||
|
||||
ConfigCombatEngine::Data ConfigCombatEngine::m_data;
|
||||
float ConfigCombatEngine::m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy+1][ServerArmorTemplate::AR_armorHeavy+1];
|
||||
|
||||
void ConfigCombatEngine::install(void)
|
||||
{
|
||||
static const std::string CONFIG_FILE("abstract/combat/combat_consts.iff");
|
||||
Iff file;
|
||||
|
||||
ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_body"), static_cast<int>(CSB_body)));
|
||||
ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_head"), static_cast<int>(CSB_head)));
|
||||
ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_rightArm"), static_cast<int>(CSB_rightArm)));
|
||||
ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_leftArm"), static_cast<int>(CSB_leftArm)));
|
||||
ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_rightLeg"), static_cast<int>(CSB_rightLeg)));
|
||||
ms_boneMap.insert(BoneMap::value_type(CrcLowerString("CSB_leftLeg"), static_cast<int>(CSB_leftLeg)));
|
||||
|
||||
installFromConfigFile();
|
||||
|
||||
if (!TreeFile::exists(CONFIG_FILE.c_str()))
|
||||
return;
|
||||
if (!file.open(CONFIG_FILE.c_str(), true))
|
||||
return;
|
||||
|
||||
Tag type = file.getCurrentName();
|
||||
if (type != TAG(C,O,M,C))
|
||||
return;
|
||||
file.enterForm();
|
||||
Tag version = file.getCurrentName();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case TAG(0,0,0,0):
|
||||
parseVersion0(file);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
file.close();
|
||||
} // ConfigCombatEngine::install
|
||||
|
||||
/**
|
||||
* Loads config info from the [CombatEngine] config file section.
|
||||
*/
|
||||
void ConfigCombatEngine::installFromConfigFile(void)
|
||||
{
|
||||
KEY_INT(debugQueues, 0);
|
||||
KEY_INT(debugTargeting, 0);
|
||||
KEY_INT(debugAttack, 0);
|
||||
KEY_INT(debugDefense, 0);
|
||||
KEY_INT(debugDamage, 0);
|
||||
KEY_INT(debugExplosion, 0);
|
||||
} // ConfigCombatEngine::installFromConfigFile
|
||||
|
||||
void ConfigCombatEngine::parseVersion0(Iff & file)
|
||||
{
|
||||
std::string paramName, tempString;
|
||||
ConfigCombatEngineData::BodyAttackMod bodyAttackMod;
|
||||
ConfigCombatEngine::SkeletonAttackMod skeletonAttackMod;
|
||||
|
||||
//-- Initialize data structures.
|
||||
memset(&bodyAttackMod, 0, sizeof(bodyAttackMod));
|
||||
memset(&skeletonAttackMod, 0, sizeof(skeletonAttackMod));
|
||||
|
||||
file.enterForm();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (file.atEndOfForm())
|
||||
break;
|
||||
|
||||
file.enterChunk();
|
||||
|
||||
file.read_string(paramName);
|
||||
if (paramName == "maxAims")
|
||||
{
|
||||
m_data.maxAims = file.read_uint8();
|
||||
}
|
||||
else if (paramName == "kineticObjectDamage")
|
||||
{
|
||||
m_data.kineticObjectDamage = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "energyObjectDamage")
|
||||
{
|
||||
m_data.energyObjectDamage = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "blastObjectDamage")
|
||||
{
|
||||
m_data.blastObjectDamage = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "stunObjectDamage")
|
||||
{
|
||||
m_data.stunObjectDamage = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "restraintObjectDamage")
|
||||
{
|
||||
m_data.restraintObjectDamage = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "elementalObjectDamage")
|
||||
{
|
||||
m_data.elementalObjectDamage = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "weaponLowerThanArmorRating")
|
||||
{
|
||||
m_data.weaponLowerThanArmorRating = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "weaponHigherThanArmorRating")
|
||||
{
|
||||
m_data.weaponHigherThanArmorRating = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "woundChance")
|
||||
{
|
||||
m_data.woundChance = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "woundPercent")
|
||||
{
|
||||
m_data.woundPercent = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "shockWoundPercent")
|
||||
{
|
||||
m_data.shockWoundPercent = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
else if (paramName == "numberSkeletons")
|
||||
{
|
||||
m_data.numberSkeletons = file.read_uint8() + 1;
|
||||
// set up all-body skeleton
|
||||
bodyAttackMod.name = "";
|
||||
bodyAttackMod.modelBoneName = "";
|
||||
bodyAttackMod.toHitChance = 100;
|
||||
bodyAttackMod.toWoundBonus = 0;
|
||||
bodyAttackMod.combatSkeletonBone = 0;
|
||||
bodyAttackMod.damageBonus[Attributes::Health] = 0;
|
||||
bodyAttackMod.damageBonus[Attributes::Action] = 0;
|
||||
bodyAttackMod.damageBonus[Attributes::Mind] = 0;
|
||||
skeletonAttackMod.name = "";
|
||||
skeletonAttackMod.numHitLocations = 1;
|
||||
skeletonAttackMod.script = "";
|
||||
skeletonAttackMod.attackMods.clear();
|
||||
skeletonAttackMod.attackMods.push_back(bodyAttackMod);
|
||||
m_data.skeletonAttackMods.push_back(skeletonAttackMod);
|
||||
}
|
||||
else if (paramName == "skeletonAttackMod")
|
||||
{
|
||||
skeletonAttackMod.attackMods.clear();
|
||||
size_t skeletonIndex = file.read_uint8() + 1;
|
||||
while (m_data.skeletonAttackMods.size() <= skeletonIndex)
|
||||
m_data.skeletonAttackMods.push_back(skeletonAttackMod);
|
||||
ConfigCombatEngine::SkeletonAttackMod & skeleton = m_data.skeletonAttackMods[skeletonIndex];
|
||||
file.read_string(tempString);
|
||||
skeleton.name = tempString;
|
||||
skeleton.numHitLocations = file.read_uint8();
|
||||
file.read_string(tempString);
|
||||
skeleton.script = tempString;
|
||||
}
|
||||
else if (paramName == "skeletonAttackLoc")
|
||||
{
|
||||
size_t skeletonIndex = file.read_uint8() + 1;
|
||||
size_t locIndex = file.read_uint8();
|
||||
while (m_data.skeletonAttackMods.size() <= skeletonIndex)
|
||||
m_data.skeletonAttackMods.push_back(skeletonAttackMod);
|
||||
ConfigCombatEngine::SkeletonAttackMod & skeleton = m_data.skeletonAttackMods[skeletonIndex];
|
||||
while (skeleton.attackMods.size() <= locIndex)
|
||||
skeleton.attackMods.push_back(bodyAttackMod);
|
||||
ConfigCombatEngineData::BodyAttackMod & bodyLoc = skeleton.attackMods[locIndex];
|
||||
file.read_string(tempString);
|
||||
bodyLoc.name = tempString;
|
||||
file.read_string(tempString);
|
||||
bodyLoc.modelBoneName = tempString;
|
||||
bodyLoc.toHitChance = file.read_uint8();
|
||||
bodyLoc.toWoundBonus = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
bodyLoc.damageBonus[Attributes::Health] = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
bodyLoc.damageBonus[Attributes::Action] = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
bodyLoc.damageBonus[Attributes::Mind] = static_cast<float>(file.read_uint8()) / 100.0f;
|
||||
}
|
||||
file.exitChunk();
|
||||
}
|
||||
|
||||
file.exitForm();
|
||||
|
||||
setupRatingDifferenceDamageReduction();
|
||||
} // ConfigCombatEngine::parseVersion0
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void ConfigCombatEngine::remove(void)
|
||||
{
|
||||
m_data.skeletonAttackMods.clear();
|
||||
ms_boneMap.clear();
|
||||
} // ConfigCombatEngine::remove
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
float ConfigCombatEngine::getObjectDamageSpread(
|
||||
ServerWeaponObjectTemplate::DamageType damageType)
|
||||
{
|
||||
switch (damageType)
|
||||
{
|
||||
case ServerWeaponObjectTemplate::DT_kinetic:
|
||||
return m_data.kineticObjectDamage;
|
||||
case ServerWeaponObjectTemplate::DT_energy:
|
||||
return m_data.energyObjectDamage;
|
||||
case ServerWeaponObjectTemplate::DT_blast:
|
||||
return m_data.blastObjectDamage;
|
||||
case ServerWeaponObjectTemplate::DT_stun:
|
||||
return m_data.stunObjectDamage;
|
||||
case ServerWeaponObjectTemplate::DT_restraint:
|
||||
return m_data.restraintObjectDamage;
|
||||
default:
|
||||
break;
|
||||
}//lint !e788 enum constant not used
|
||||
return 1.0f;
|
||||
} // ConfigCombatEngine::getObjectDamageSpread
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets up the RatingDifferenceDamageReduction table.
|
||||
*/
|
||||
void ConfigCombatEngine::setupRatingDifferenceDamageReduction(void)
|
||||
{
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorNone][ServerArmorTemplate::AR_armorNone] = 1.0f;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorNone][ServerArmorTemplate::AR_armorLight] = m_data.weaponLowerThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorNone][ServerArmorTemplate::AR_armorMedium] = m_data.weaponLowerThanArmorRating * m_data.weaponLowerThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorNone][ServerArmorTemplate::AR_armorHeavy] = m_data.weaponLowerThanArmorRating * m_data.weaponLowerThanArmorRating * m_data.weaponLowerThanArmorRating;
|
||||
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorLight][ServerArmorTemplate::AR_armorNone] = m_data.weaponHigherThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorLight][ServerArmorTemplate::AR_armorLight] = 1.0f;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorLight][ServerArmorTemplate::AR_armorMedium] = m_data.weaponLowerThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorLight][ServerArmorTemplate::AR_armorHeavy] = m_data.weaponLowerThanArmorRating * m_data.weaponLowerThanArmorRating;
|
||||
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorMedium][ServerArmorTemplate::AR_armorNone] = m_data.weaponHigherThanArmorRating * m_data.weaponHigherThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorMedium][ServerArmorTemplate::AR_armorLight] = m_data.weaponHigherThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorMedium][ServerArmorTemplate::AR_armorMedium] = 1.0f;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorMedium][ServerArmorTemplate::AR_armorHeavy] = m_data.weaponLowerThanArmorRating;
|
||||
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy][ServerArmorTemplate::AR_armorNone] = m_data.weaponHigherThanArmorRating * m_data.weaponHigherThanArmorRating * m_data.weaponHigherThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy][ServerArmorTemplate::AR_armorLight] = m_data.weaponHigherThanArmorRating * m_data.weaponHigherThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy][ServerArmorTemplate::AR_armorMedium] = m_data.weaponHigherThanArmorRating;
|
||||
m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::AR_armorHeavy][ServerArmorTemplate::AR_armorHeavy] = 1.0f;
|
||||
} // ConfigCombatEngine::setupRatingDifferenceDamageReduction
|
||||
@@ -0,0 +1,229 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ConfigCombatEngine.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
|
||||
#ifndef _INCLUDED_ConfigCombatEngine_H
|
||||
#define _INCLUDED_ConfigCombatEngine_H
|
||||
|
||||
#include "serverGame/ServerArmorTemplate.h"
|
||||
#include "serverGame/ServerTangibleObjectTemplate.h"
|
||||
#include "serverGame/ServerWeaponObjectTemplate.h"
|
||||
#include "swgSharedUtility/CombatEngineData.h"
|
||||
#include "swgSharedUtility/Attributes.def"
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// namespace ConfigCombatEngineData
|
||||
|
||||
namespace ConfigCombatEngineData
|
||||
{
|
||||
struct BodyAttackMod
|
||||
{
|
||||
std::string name;
|
||||
std::string modelBoneName; // name of a 3d-model bone to associate with
|
||||
uint32 combatSkeletonBone;
|
||||
int toHitChance;
|
||||
float toWoundBonus;
|
||||
float damageBonus[Attributes::NumberOfAttributes];
|
||||
};
|
||||
};//lint !e19 Useless declaration
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// class ConfigCombatEngine
|
||||
|
||||
class ConfigCombatEngine
|
||||
{
|
||||
public:
|
||||
|
||||
struct AggressionMod
|
||||
{
|
||||
float time;
|
||||
int toHit;
|
||||
};
|
||||
|
||||
struct SkeletonAttackMod
|
||||
{
|
||||
std::string name;
|
||||
int numHitLocations;
|
||||
std::string script;
|
||||
std::vector<ConfigCombatEngineData::BodyAttackMod> attackMods;
|
||||
};
|
||||
|
||||
struct Data
|
||||
{
|
||||
int maxAims;
|
||||
int numberSkeletons;
|
||||
std::vector<SkeletonAttackMod> skeletonAttackMods;
|
||||
float kineticObjectDamage;
|
||||
float energyObjectDamage;
|
||||
float blastObjectDamage;
|
||||
float stunObjectDamage;
|
||||
float restraintObjectDamage;
|
||||
float elementalObjectDamage;
|
||||
float weaponLowerThanArmorRating;
|
||||
float weaponHigherThanArmorRating;
|
||||
float woundChance;
|
||||
float woundPercent;
|
||||
float shockWoundPercent;
|
||||
int numCombatStates;
|
||||
|
||||
int debugQueues;
|
||||
int debugTargeting;
|
||||
int debugAttack;
|
||||
int debugDefense;
|
||||
int debugDamage;
|
||||
int debugExplosion;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
static void install (void);
|
||||
static void remove (void);
|
||||
|
||||
static int getMaxAims(void);
|
||||
static int getNumberSkeletons(void);
|
||||
static const SkeletonAttackMod & getSkeletonAttackMod(ServerTangibleObjectTemplate::CombatSkeleton skeleton);
|
||||
static float getKineticObjectDamage(void);
|
||||
static float getEnergyObjectDamage(void);
|
||||
static float getBlastObjectDamage(void);
|
||||
static float getStunObjectDamage(void);
|
||||
static float getRestraintObjectDamage(void);
|
||||
static float getElementalObjectDamage(void);
|
||||
static float getObjectDamageSpread(ServerWeaponObjectTemplate::DamageType damageType);
|
||||
static float getWoundChance(void);
|
||||
static float getWoundPercent(void);
|
||||
static float getShockWoundPercent(void);
|
||||
|
||||
static int getDebugQueues(void);
|
||||
static int getDebugTargeting(void);
|
||||
static int getDebugAttack(void);
|
||||
static int getDebugDefense(void);
|
||||
static int getDebugDamage(void);
|
||||
static int getDebugExplosion(void);
|
||||
|
||||
private:
|
||||
|
||||
static Data m_data;
|
||||
// static ConfigCombatEngineData::BodyAttackMod m_bodyAttackMod;
|
||||
// static SkeletonAttackMod m_skeletonAttackMod;
|
||||
static float m_RatingDifferenceDamageReduction[ServerWeaponObjectTemplate::ArmorRating_Last+1][ServerArmorTemplate::ArmorRating_Last+1]; //lint !e641 converting enum to int
|
||||
|
||||
static void installFromConfigFile(void);
|
||||
static void parseVersion0(Iff & file);
|
||||
static void setupRatingDifferenceDamageReduction(void);
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCombatEngine::getMaxAims(void)
|
||||
{
|
||||
return m_data.maxAims;
|
||||
} // ConfigCombatEngine::getMaxAims
|
||||
|
||||
inline int ConfigCombatEngine::getNumberSkeletons(void)
|
||||
{
|
||||
return m_data.numberSkeletons;
|
||||
} // ConfigCombatEngine::getNumberSkeletons
|
||||
|
||||
inline const ConfigCombatEngine::SkeletonAttackMod &
|
||||
ConfigCombatEngine::getSkeletonAttackMod(
|
||||
ServerTangibleObjectTemplate::CombatSkeleton skeleton)
|
||||
{
|
||||
int sk = static_cast<int>(skeleton);
|
||||
if (sk < 0 || static_cast<size_t>(skeleton) >=
|
||||
m_data.skeletonAttackMods.size())
|
||||
{
|
||||
WARNING_STRICT_FATAL(true, ("ConfigCombatEngine::SkeletonAttackMod "
|
||||
"requested invalid skeleton %d", skeleton));
|
||||
// if we're not strict, use the default skeleton values
|
||||
skeleton = ServerTangibleObjectTemplate::CS_none;
|
||||
}
|
||||
return m_data.skeletonAttackMods[skeleton]; //lint !e641 Converting enum CombatSkeleton to int
|
||||
} // ConfigCombatEngine::getSkeletonAttackMods
|
||||
|
||||
inline float ConfigCombatEngine::getKineticObjectDamage(void)
|
||||
{
|
||||
return m_data.kineticObjectDamage;
|
||||
} // ConfigCombatEngine::getKineticObjectDamage
|
||||
|
||||
inline float ConfigCombatEngine::getEnergyObjectDamage(void)
|
||||
{
|
||||
return m_data.energyObjectDamage;
|
||||
} // ConfigCombatEngine::getEnergyObjectDamage
|
||||
|
||||
inline float ConfigCombatEngine::getBlastObjectDamage(void)
|
||||
{
|
||||
return m_data.blastObjectDamage;
|
||||
} // ConfigCombatEngine::getBlastObjectDamage
|
||||
|
||||
inline float ConfigCombatEngine::getStunObjectDamage(void)
|
||||
{
|
||||
return m_data.stunObjectDamage;
|
||||
} // ConfigCombatEngine::getStunObjectDamage
|
||||
|
||||
inline float ConfigCombatEngine::getRestraintObjectDamage(void)
|
||||
{
|
||||
return m_data.restraintObjectDamage;
|
||||
} // ConfigCombatEngine::getRestraintObjectDamage
|
||||
|
||||
inline float ConfigCombatEngine::getElementalObjectDamage(void)
|
||||
{
|
||||
return m_data.elementalObjectDamage;
|
||||
} // ConfigCombatEngine::getElementalObjectDamage
|
||||
|
||||
inline float ConfigCombatEngine::getWoundChance(void)
|
||||
{
|
||||
return m_data.woundChance;
|
||||
} // ConfigCombatEngine::getWoundChance
|
||||
|
||||
inline float ConfigCombatEngine::getWoundPercent(void)
|
||||
{
|
||||
return m_data.woundPercent;
|
||||
} // ConfigCombatEngine::getWoundPercent
|
||||
|
||||
inline float ConfigCombatEngine::getShockWoundPercent(void)
|
||||
{
|
||||
return m_data.shockWoundPercent;
|
||||
} // ConfigCombatEngine::getShockWoundPercent
|
||||
|
||||
inline int ConfigCombatEngine::getDebugQueues(void)
|
||||
{
|
||||
return m_data.debugQueues;
|
||||
} // ConfigCombatEngine::getDebugQueues
|
||||
|
||||
inline int ConfigCombatEngine::getDebugTargeting(void)
|
||||
{
|
||||
return m_data.debugTargeting;
|
||||
} // ConfigCombatEngine::getDebugTargeting
|
||||
|
||||
inline int ConfigCombatEngine::getDebugAttack(void)
|
||||
{
|
||||
return m_data.debugAttack;
|
||||
} // ConfigCombatEngine::getDebugAttack
|
||||
|
||||
inline int ConfigCombatEngine::getDebugDefense(void)
|
||||
{
|
||||
return m_data.debugDefense;
|
||||
} // ConfigCombatEngine::getDebugDefense
|
||||
|
||||
inline int ConfigCombatEngine::getDebugDamage(void)
|
||||
{
|
||||
return m_data.debugDamage;
|
||||
} // ConfigCombatEngine::getDebugDamage
|
||||
|
||||
inline int ConfigCombatEngine::getDebugExplosion(void)
|
||||
{
|
||||
return m_data.debugExplosion;
|
||||
} // ConfigCombatEngine::getDebugExplosion
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // _INCLUDED_ConfigCombatEngine_H
|
||||
@@ -0,0 +1,32 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// combat.def
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ***IMPORTTANT: This file is mirrored in dsrc/include
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_combat_DEF
|
||||
#define INCLUDED_combat_DEF
|
||||
|
||||
// id's for combat skeleton "bones" so when we know where a creature got hit we know what
|
||||
// item was protecting that area
|
||||
//
|
||||
// IMPORTANT: the skeleton location names in the combat.cfg file should map to these
|
||||
//
|
||||
enum CombatSkeletonBone
|
||||
{
|
||||
CSB_body = 0x0001,
|
||||
CSB_head = 0x0002,
|
||||
CSB_rightArm = 0x0004,
|
||||
CSB_leftArm = 0x0008,
|
||||
CSB_rightLeg = 0x0010,
|
||||
CSB_leftLeg = 0x0020
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConsoleCommandParserCombatEngine.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "CombatEngine.h"
|
||||
|
||||
#include "UnicodeUtils.h"
|
||||
#include "ConsoleCommandParserCombatEngine.h"
|
||||
#include "ConsoleCommandParserCombatEngineQueue.h"
|
||||
#include "serverGame/ServerWorld.h"
|
||||
#include "serverGame/CreatureController.h"
|
||||
#include "serverGame/CreatureObject.h"
|
||||
#include "serverGame/WeaponObject.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
static const CommandParser::CmdInfo cmds[] =
|
||||
{
|
||||
{"reload", 0, "", "Reloads the combat data from the config file."},
|
||||
{"", 0, "", ""} // this must be last
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
ConsoleCommandParserCombatEngine::ConsoleCommandParserCombatEngine (void) :
|
||||
CommandParser ("combat", 0, "...", "Combat related commands.", 0)
|
||||
{
|
||||
createDelegateCommands (cmds);
|
||||
IGNORE_RETURN(addSubCommand(new ConsoleCommandParserCombatEngineQueue()));//lint !e1524 (owned by the base class command parser)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
bool ConsoleCommandParserCombatEngine::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & originalCommand, String_t & result, const CommandParser * node)
|
||||
{
|
||||
NOT_NULL (node);
|
||||
UNREF (userId);
|
||||
|
||||
UNREF(originalCommand);
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
if (isAbbrev( argv [0], "reload"))
|
||||
{
|
||||
if (CombatEngine::reloadCombatData())
|
||||
result += getErrorMessage(argv[0], ERR_SUCCESS);
|
||||
else
|
||||
result += getErrorMessage(argv[0], ERR_NO_ERROR_MSG);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
else
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_NO_HANDLER);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
// ======================================================================
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConsoleCommandParserCombatEngine.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_ConsoleCommandParserCombatEngine_H
|
||||
#define INCLUDED_ConsoleCommandParserCombatEngine_H
|
||||
|
||||
#include "sharedCommandParser/CommandParser.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Commands that are related to the combat engine
|
||||
*/
|
||||
|
||||
class ConsoleCommandParserCombatEngine : public CommandParser
|
||||
{
|
||||
public:
|
||||
ConsoleCommandParserCombatEngine ();
|
||||
virtual bool performParsing (const NetworkId & userId,
|
||||
const StringVector_t & argv,
|
||||
const String_t & originalCommand,
|
||||
String_t & result,
|
||||
const CommandParser * node);
|
||||
|
||||
private:
|
||||
ConsoleCommandParserCombatEngine (const ConsoleCommandParserCombatEngine & rhs);
|
||||
ConsoleCommandParserCombatEngine & operator= (const ConsoleCommandParserCombatEngine & rhs);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // INCLUDED_ConsoleCommandParserCombatEngine_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConsoleCommandParserCombatEngineQueue.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "ConsoleCommandParserCombatEngineQueue.h"
|
||||
|
||||
#include "CombatEngine.h"
|
||||
#include "UnicodeUtils.h"
|
||||
#include "serverGame/ServerWorld.h"
|
||||
#include "serverGame/CreatureObject.h"
|
||||
#include "serverGame/TangibleObject.h"
|
||||
#include "sharedFoundation/NetworkIdArchive.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
static const CommandParser::CmdInfo cmds[] =
|
||||
{
|
||||
{"target", 1, "<oid>", "Target an object (oid 0 = no target)."},
|
||||
{"attack", 0, "<weapon oid> <mode>", "Attack current target with weapon."},
|
||||
{"aim", 0, "", "Add aim."},
|
||||
{"attitude", 1, "<attitude>", "Change combat attitude (queued)."},
|
||||
{"posture", 1, "<posture>", "Change combat posture (queued)."},
|
||||
{"", 0, "", ""} // this must be last
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
ConsoleCommandParserCombatEngineQueue::ConsoleCommandParserCombatEngineQueue (void) :
|
||||
CommandParser ("queue", 0, "...", "Action queue commands.", 0)
|
||||
{
|
||||
createDelegateCommands (cmds);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
|
||||
bool ConsoleCommandParserCombatEngineQueue::performParsing (const NetworkId & userId,
|
||||
const StringVector_t & argv, const String_t & originalCommand, String_t & result,
|
||||
const CommandParser * node)
|
||||
{
|
||||
NOT_NULL (node);
|
||||
UNREF (userId);
|
||||
|
||||
UNREF(originalCommand);
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
if (isAbbrev( argv [0], "target"))
|
||||
{
|
||||
Object *object = ServerWorld::findObjectByNetworkId(userId);
|
||||
if (! object)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_INVALID_USER);
|
||||
return true;
|
||||
}
|
||||
TangibleObject *attacker = dynamic_cast<TangibleObject *>(object);
|
||||
if (! attacker)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_BAD_ATTACKER);
|
||||
return true;
|
||||
}
|
||||
|
||||
CombatEngineData::TargetIdList targets;
|
||||
CachedNetworkId oid((Unicode::wideToNarrow(argv[1]))); //lint !e747 Info: 747 - Significant prototype coercion (arg. no. 1) int to long long
|
||||
if (oid.getValue() != 0)
|
||||
{
|
||||
targets.push_back(oid);
|
||||
}
|
||||
|
||||
if (CombatEngine::addTargetAction(*attacker, targets))
|
||||
result += getErrorMessage(argv[0], ERR_SUCCESS);
|
||||
else
|
||||
result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
else if (isAbbrev( argv [0], "attack"))
|
||||
{
|
||||
Object *object = ServerWorld::findObjectByNetworkId(userId);
|
||||
if (! object)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_INVALID_USER);
|
||||
return true;
|
||||
}
|
||||
TangibleObject *attacker = dynamic_cast<TangibleObject *>(object);
|
||||
if (! attacker)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_BAD_ATTACKER);
|
||||
return true;
|
||||
}
|
||||
|
||||
NetworkId weapon;
|
||||
unsigned int mode = 0;
|
||||
if (argv.size() >= 2)
|
||||
weapon = NetworkId(Unicode::wideToNarrow(argv[1]));
|
||||
if (argv.size() >= 3)
|
||||
mode = strtoul(Unicode::wideToNarrow(argv[2]).c_str (), 0, 10);
|
||||
if (CombatEngine::addAttackAction(*attacker, weapon, static_cast<int>(mode)))
|
||||
result += getErrorMessage(argv[0], ERR_SUCCESS);
|
||||
else
|
||||
result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
else if (isAbbrev( argv [0], "aim"))
|
||||
{
|
||||
Object *object = ServerWorld::findObjectByNetworkId(userId);
|
||||
if (! object)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_INVALID_USER);
|
||||
return true;
|
||||
}
|
||||
TangibleObject *attacker = dynamic_cast<TangibleObject *>(object);
|
||||
if (! attacker)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_BAD_ATTACKER);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CombatEngine::addAimAction(*attacker))
|
||||
result += getErrorMessage(argv[0], ERR_SUCCESS);
|
||||
else
|
||||
result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
else if (isAbbrev( argv [0], "attitude"))
|
||||
{
|
||||
Object *object = ServerWorld::findObjectByNetworkId(userId);
|
||||
if (! object)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_INVALID_USER);
|
||||
return true;
|
||||
}
|
||||
TangibleObject *attacker = dynamic_cast<TangibleObject *>(object);
|
||||
if (! attacker)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_BAD_ATTACKER);
|
||||
return true;
|
||||
}
|
||||
|
||||
// int attitude = strtoul(Unicode::wideToNarrow(argv[1]).c_str (), 0, 10);
|
||||
|
||||
// if (CombatEngine::addAttitudeAction(*attacker, attitude))
|
||||
// result += getErrorMessage(argv[0], ERR_SUCCESS);
|
||||
// else
|
||||
result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
else if (isAbbrev( argv [0], "posture"))
|
||||
{
|
||||
Object *object = ServerWorld::findObjectByNetworkId(userId);
|
||||
if (! object)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_INVALID_USER);
|
||||
return true;
|
||||
}
|
||||
CreatureObject *attacker = dynamic_cast<CreatureObject *>(object);
|
||||
if (! attacker)
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_BAD_ATTACKER);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Postures::Enumerator posture = static_cast<Postures::Enumerator>(strtoul(
|
||||
// Unicode::wideToNarrow(argv[1]).c_str (), 0, 10));
|
||||
|
||||
// if (CombatEngine::addPostureAction(*attacker, posture))
|
||||
// result += getErrorMessage(argv[0], ERR_SUCCESS);
|
||||
// else
|
||||
result += getErrorMessage(argv[0], ERR_QUEUE_COMMAND_FAIL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
else
|
||||
{
|
||||
result += getErrorMessage(argv[0], ERR_NO_HANDLER);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
// ======================================================================
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConsoleCommandParserCombatEngineQueue.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_ConsoleCommandParserCombatEngineQueue_H
|
||||
#define INCLUDED_ConsoleCommandParserCombatEngineQueue_H
|
||||
|
||||
#include "sharedCommandParser/CommandParser.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Commands that are related to the combat engine
|
||||
*/
|
||||
|
||||
class ConsoleCommandParserCombatEngineQueue : public CommandParser
|
||||
{
|
||||
public:
|
||||
ConsoleCommandParserCombatEngineQueue ();
|
||||
virtual bool performParsing (const NetworkId & userId,
|
||||
const StringVector_t & argv,
|
||||
const String_t & originalCommand,
|
||||
String_t & result,
|
||||
const CommandParser * node);
|
||||
|
||||
private:
|
||||
ConsoleCommandParserCombatEngineQueue (const ConsoleCommandParserCombatEngineQueue & rhs);
|
||||
ConsoleCommandParserCombatEngineQueue & operator= (const ConsoleCommandParserCombatEngineQueue & rhs);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // INCLUDED_ConsoleCommandParserCombatEngineQueue_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
//========================================================================
|
||||
//
|
||||
// JediManagerController.cpp
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/JediManagerController.h"
|
||||
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
|
||||
#include "SwgGameServer/JediManagerObject.h"
|
||||
#include "swgServerNetworkMessages/MessageQueueJediData.h"
|
||||
#include "swgServerNetworkMessages/MessageQueueJediLocation.h"
|
||||
#include "swgServerNetworkMessages/MessageQueueRequestJediBounty.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
JediManagerController::JediManagerController(JediManagerObject * newOwner) :
|
||||
UniverseController(newOwner)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
JediManagerController::~JediManagerController()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void JediManagerController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
|
||||
{
|
||||
JediManagerObject * owner = dynamic_cast<JediManagerObject *>(getOwner());
|
||||
NOT_NULL(owner);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case CM_removeJedi:
|
||||
{
|
||||
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->removeJedi(msg->getValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_addJedi:
|
||||
{
|
||||
const MessageQueueJediData * const msg = safe_cast<const MessageQueueJediData *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->addJedi(msg->getId(),
|
||||
msg->getName(),
|
||||
msg->getLocation(),
|
||||
msg->getScene(),
|
||||
msg->getVisibility(),
|
||||
msg->getBountyValue(),
|
||||
msg->getLevel(),
|
||||
msg->getHoursAlive(),
|
||||
msg->getState(),
|
||||
msg->getSpentJediSkillPoints(),
|
||||
msg->getFaction()
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_updateJedi:
|
||||
{
|
||||
const MessageQueueJediData * const msg = safe_cast<const MessageQueueJediData *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->updateJedi(msg->getId(),
|
||||
msg->getVisibility(),
|
||||
msg->getBountyValue(),
|
||||
msg->getLevel(),
|
||||
msg->getHoursAlive()
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_updateJediState:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->updateJedi(msg->getValue().first,
|
||||
static_cast<JediState>(msg->getValue().second)
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_updateJediBounties:
|
||||
{
|
||||
/*
|
||||
const MessageQueueGenericValueType<std::pair<NetworkId, std::vector<NetworkId> > > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, std::vector<NetworkId> > > *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->updateJedi(msg->getValue().first,
|
||||
msg->getValue().second
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
||||
break;
|
||||
case CM_updateJediLocation:
|
||||
{
|
||||
const MessageQueueJediLocation * const msg = safe_cast<const MessageQueueJediLocation *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->updateJediLocation(msg->getId(),
|
||||
msg->getLocation(),
|
||||
msg->getScene()
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_setJediOffline:
|
||||
{
|
||||
const MessageQueueJediLocation * const msg = safe_cast<const MessageQueueJediLocation *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->setJediOffline(msg->getId(),
|
||||
msg->getLocation(),
|
||||
msg->getScene()
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_requestJediBounty:
|
||||
{
|
||||
const MessageQueueRequestJediBounty * const msg = safe_cast<const MessageQueueRequestJediBounty *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->requestJediBounty(msg->getTargetId(),
|
||||
msg->getHunterId(),
|
||||
msg->getSuccessCallback(),
|
||||
msg->getFailCallback(),
|
||||
msg->getCallbackObjectId()
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_removeJediBounty:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, NetworkId> > *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->removeJediBounty(msg->getValue().first, msg->getValue().second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_removeAllJediBounties:
|
||||
{
|
||||
const MessageQueueGenericValueType<NetworkId> * const msg = safe_cast<const MessageQueueGenericValueType<NetworkId> *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->removeAllJediBounties(msg->getValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_updateJediSpentJediSkillPoints:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->updateJediSpentJediSkillPoints(msg->getValue().first, msg->getValue().second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_updateJediFaction:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::pair<NetworkId, int> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, int> > *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->updateJediFaction(msg->getValue().first, msg->getValue().second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_updateJediScriptData:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::pair<NetworkId, std::pair<std::string, int> > > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, std::pair<std::string, int> > > *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->updateJediScriptData(msg->getValue().first, msg->getValue().second.first, msg->getValue().second.second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CM_removeJediScriptData:
|
||||
{
|
||||
const MessageQueueGenericValueType<std::pair<NetworkId, std::string> > * const msg = safe_cast<const MessageQueueGenericValueType<std::pair<NetworkId, std::string> > *>(data);
|
||||
if (msg != NULL)
|
||||
{
|
||||
owner->removeJediScriptData(msg->getValue().first, msg->getValue().second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
UniverseController::handleMessage(message, value, data, flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,42 @@
|
||||
//========================================================================
|
||||
//
|
||||
// JediManagerController.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef INCLUDED_JediManagerController_H
|
||||
#define INCLUDED_JediManagerController_H
|
||||
|
||||
#include "serverGame/UniverseController.h"
|
||||
|
||||
class JediManagerObject;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* A generic controller for all JediManager Objects.
|
||||
*/
|
||||
class JediManagerController : public UniverseController
|
||||
{
|
||||
public:
|
||||
explicit JediManagerController (JediManagerObject * newOwner);
|
||||
virtual ~JediManagerController (void);
|
||||
|
||||
protected:
|
||||
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
|
||||
|
||||
private:
|
||||
JediManagerController (void);
|
||||
JediManagerController (const JediManagerController & other);
|
||||
JediManagerController& operator= (const JediManagerController & other);
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // INCLUDED_JediManagerController_H
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// SwgPlayerCreatureController.cpp
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/SwgPlayerCreatureController.h"
|
||||
|
||||
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
|
||||
#include "SwgGameServer/SwgCreatureObject.h"
|
||||
#include "SwgGameServer/SwgPlayerObject.h"
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
SwgPlayerCreatureController::SwgPlayerCreatureController(SwgCreatureObject *newOwner) :
|
||||
PlayerCreatureController(newOwner)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
SwgPlayerCreatureController::~SwgPlayerCreatureController()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void SwgPlayerCreatureController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags)
|
||||
{
|
||||
SwgCreatureObject * const owner = safe_cast<SwgCreatureObject*>(getOwner());
|
||||
SwgPlayerObject * playerOwner = safe_cast<SwgPlayerObject*>(getPlayerObject(owner));
|
||||
NOT_NULL(playerOwner);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case CM_setJediState:
|
||||
{
|
||||
const MessageQueueGenericValueType<int> * const msg = dynamic_cast<const MessageQueueGenericValueType<int> *>(data);
|
||||
if (msg != NULL)
|
||||
playerOwner->setJediState(static_cast<JediState>(msg->getValue()));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
PlayerCreatureController::handleMessage(message, value, data, flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgPlayerCreatureController.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef INCLUDED_SwgPlayerCreatureController_H
|
||||
#define INCLUDED_SwgPlayerCreatureController_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverGame/PlayerCreatureController.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class SwgCreatureObject;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class SwgPlayerCreatureController : public PlayerCreatureController
|
||||
{
|
||||
public:
|
||||
explicit SwgPlayerCreatureController (SwgCreatureObject * newOwner);
|
||||
~SwgPlayerCreatureController ();
|
||||
|
||||
protected:
|
||||
virtual void handleMessage (int message, float value, const MessageQueue::Data* data, uint32 flags);
|
||||
|
||||
private:
|
||||
// Disabled.
|
||||
SwgPlayerCreatureController (void);
|
||||
SwgPlayerCreatureController (const SwgPlayerCreatureController & other);
|
||||
SwgPlayerCreatureController& operator= (const SwgPlayerCreatureController & other);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
#endif // INCLUDED_SwgPlayerCreatureController_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
||||
//CSHandler.h
|
||||
// copyright 2005 Sony Online Entertainment
|
||||
//-----------------------------------------------
|
||||
// handler class for CS requests.
|
||||
|
||||
#ifndef _CSHANDLER_H
|
||||
#define _CSHANDLER_H
|
||||
|
||||
|
||||
|
||||
|
||||
#define DECLARE_CS_HANDLER( _name_ ) void handle_##_name_( CSHandlerRequest & request, GameServerCSResponseMessage & msg );
|
||||
|
||||
class GameServerCSRequestMessage;
|
||||
class GameServerCSResponseMessage;
|
||||
|
||||
class CSHandlerRequest
|
||||
{
|
||||
public:
|
||||
CSHandlerRequest( const std::string & command,
|
||||
const std::string & args,
|
||||
const uint32 access,
|
||||
const std::string & username );
|
||||
|
||||
std::string m_command;
|
||||
std::string m_args;
|
||||
uint32 m_access;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
class CSHandler
|
||||
{
|
||||
public:
|
||||
|
||||
static void remove();
|
||||
|
||||
void handle( GameServerCSRequestMessage & request );
|
||||
static void install();
|
||||
static CSHandler& getInstance();
|
||||
|
||||
// handlers
|
||||
DECLARE_CS_HANDLER( get_pc_info );
|
||||
DECLARE_CS_HANDLER( set_bank_credits );
|
||||
DECLARE_CS_HANDLER( undelete_item );
|
||||
DECLARE_CS_HANDLER( list_objvars );
|
||||
DECLARE_CS_HANDLER( set_objvar );
|
||||
DECLARE_CS_HANDLER( remove_objvar );
|
||||
DECLARE_CS_HANDLER( dump_info );
|
||||
DECLARE_CS_HANDLER( rename_player );
|
||||
|
||||
DECLARE_CS_HANDLER( freeze );
|
||||
DECLARE_CS_HANDLER( unfreeze );
|
||||
|
||||
DECLARE_CS_HANDLER( get_player_id );
|
||||
DECLARE_CS_HANDLER( get_player_items );
|
||||
|
||||
DECLARE_CS_HANDLER( move_object );
|
||||
DECLARE_CS_HANDLER( delete_object );
|
||||
|
||||
DECLARE_CS_HANDLER( create_crafted_object );
|
||||
|
||||
DECLARE_CS_HANDLER( adjust_lots );
|
||||
|
||||
DECLARE_CS_HANDLER( warp_player );
|
||||
|
||||
private:
|
||||
void registerCommands();
|
||||
|
||||
static CSHandler * sm_instance;
|
||||
CSHandler();
|
||||
virtual ~CSHandler();
|
||||
|
||||
};
|
||||
|
||||
|
||||
typedef void( CSHandler::*CSHandlerFunc )( CSHandlerRequest &, GameServerCSResponseMessage & );
|
||||
|
||||
class CSHandlerEntry
|
||||
{
|
||||
public:
|
||||
CSHandlerEntry();
|
||||
CSHandlerEntry( const std::string & name, uint32 access, CSHandlerFunc handler );
|
||||
std::string sCommand;
|
||||
uint32 access;
|
||||
CSHandlerFunc handlerFunc;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
#endif // _CSHANDLER_H
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstSwgGameServer.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_FirstSwgGameServer_H
|
||||
#define INCLUDED_FirstSwgGameServer_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#pragma warning ( disable : 4503 ) // name truncated (STL)
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedDebug/FirstSharedDebug.h"
|
||||
#include "sharedMemoryManager/FirstSharedMemoryManager.h"
|
||||
|
||||
#include "StringId.h"
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// SwgGameServer.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/SwgGameServer.h"
|
||||
#include "serverGame/CommoditiesMarket.h"
|
||||
#include "serverGame/PreloadManager.h"
|
||||
#include "serverNetworkMessages/BountyHunterTargetListMessage.h"
|
||||
#include "serverNetworkMessages/GameServerCSRequestMessage.h"
|
||||
#include "serverNetworkMessages/GameServerCSResponseMessage.h"
|
||||
#include "sharedDebug/Profiler.h"
|
||||
#include "sharedGame/AppearanceManager.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedMessageDispatch/MessageManager.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "SwgGameServer/CombatEngine.h"
|
||||
#include "SwgGameServer/JediManagerObject.h"
|
||||
#include "SwgGameServer/ServerJediManagerObjectTemplate.h"
|
||||
#include "SwgGameServer/SwgServerCreatureObjectTemplate.h"
|
||||
#include "SwgGameServer/SwgServerPlayerObjectTemplate.h"
|
||||
#include "SwgGameServer/SwgServerUniverse.h"
|
||||
#include "SwgGameServer/CSHandler.h"
|
||||
|
||||
|
||||
//#undef PROFILE_INDIVIDUAL_MESSAGES
|
||||
#define PROFILE_INDIVIDUAL_MESSAGES 1
|
||||
|
||||
#ifdef PROFILE_INDIVIDUAL_MESSAGES
|
||||
#define MESSAGE_PROFILER_BLOCK(a) PROFILER_AUTO_BLOCK_DEFINE(a)
|
||||
#else
|
||||
#define MESSAGE_PROFILER_BLOCK(a) NOP
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
SwgGameServer::SwgGameServer() :
|
||||
GameServer()
|
||||
{
|
||||
connectToMessage("BountyHunterTargetListMessage");
|
||||
connectToMessage("DeleteCharacterNotificationMessage");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
SwgGameServer::~SwgGameServer()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void SwgGameServer::install()
|
||||
{
|
||||
DEBUG_FATAL (ms_instance != NULL, ("already installed"));
|
||||
ms_instance = new SwgGameServer;
|
||||
|
||||
SwgServerUniverse::install();
|
||||
CombatEngine::install();
|
||||
ServerJediManagerObjectTemplate::install();
|
||||
SwgServerCreatureObjectTemplate::install();
|
||||
SwgServerPlayerObjectTemplate::install();
|
||||
// the preload manager MUST be installed after the SwgServer... templates
|
||||
PreloadManager::install();
|
||||
CommoditiesMarket::install();
|
||||
|
||||
CSHandler::install();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void SwgGameServer::initialize()
|
||||
{
|
||||
GameServer::initialize();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void SwgGameServer::shutdown()
|
||||
{
|
||||
GameServer::shutdown();
|
||||
CommoditiesMarket::remove();
|
||||
CSHandler::remove();
|
||||
}
|
||||
|
||||
void SwgGameServer::handleCSRequest( GameServerCSRequestMessage & request )
|
||||
{
|
||||
CSHandler::getInstance().handle( request );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void SwgGameServer::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
|
||||
{
|
||||
static Archive::ReadIterator ri;
|
||||
static Archive::ByteStream bs;
|
||||
|
||||
PROFILER_AUTO_BLOCK_DEFINE("SwgGameServer::receiveMessage");
|
||||
|
||||
if (message.isType("BountyHunterTargetListMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("SwgGameServer: got BountyHunterTargetListMessage\n"));
|
||||
MESSAGE_PROFILER_BLOCK("BountyHunterTargetListMessage");
|
||||
ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
const BountyHunterTargetListMessage * msg = new BountyHunterTargetListMessage(ri);
|
||||
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(
|
||||
ServerUniverse::getInstance()).getJediManager();
|
||||
|
||||
if (jediManager != NULL && jediManager->isAuthoritative())
|
||||
{
|
||||
jediManager->addJediBounties(*msg);
|
||||
delete msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("BountyHunterTargetList", ("Queuing BountyHunterTargetList from DB because JediManagerObject is not yet ready"));
|
||||
JediManagerObject::queueBountyHunterTargetListFromDB(msg);
|
||||
}
|
||||
}
|
||||
else if (message.isType("DeleteCharacterNotificationMessage"))
|
||||
{
|
||||
ri = static_cast<const GameNetworkMessage &>(message).getByteStream().begin();
|
||||
const GenericValueTypeMessage<NetworkId> msg(ri);
|
||||
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(
|
||||
ServerUniverse::getInstance()).getJediManager();
|
||||
|
||||
if (jediManager != NULL)
|
||||
{
|
||||
jediManager->characterBeingDeleted(msg.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// GameServer::receiveMessage does some bookkeeping stuff, so always call it
|
||||
GameServer::receiveMessage(source, message);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// SwgGameServer.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_SwgGameServer_H
|
||||
#define INCLUDED_SwgGameServer_H
|
||||
|
||||
#include "serverGame/GameServer.h"
|
||||
|
||||
class SwgGameServer : public GameServer
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~SwgGameServer();
|
||||
|
||||
static void install();
|
||||
|
||||
virtual void receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message);
|
||||
|
||||
virtual void handleCSRequest( GameServerCSRequestMessage & request );
|
||||
|
||||
protected:
|
||||
SwgGameServer();
|
||||
virtual void initialize ();
|
||||
virtual void shutdown ();
|
||||
|
||||
private:
|
||||
SwgGameServer (const SwgGameServer & source);
|
||||
SwgGameServer & operator = (const SwgGameServer & rhs);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// SwgServerUniverse.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/SwgServerUniverse.h"
|
||||
#include "serverGame/ConfigServerGame.h"
|
||||
#include "serverGame/ServerObjectTemplate.h"
|
||||
#include "serverGame/ServerWorld.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
#include "SwgGameServer/JediManagerObject.h"
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void SwgServerUniverse::install()
|
||||
{
|
||||
Universe::installDerived(new SwgServerUniverse);
|
||||
ServerUniverse::install();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
SwgServerUniverse::SwgServerUniverse() :
|
||||
ServerUniverse (),
|
||||
m_jediManager (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
SwgServerUniverse::~SwgServerUniverse()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Check the Universe Objects. Spawn new objects as
|
||||
* needed, update the amount remaining on all the resource pools, etc.
|
||||
*
|
||||
* May be time consuming, so this should not be called every frame.
|
||||
*/
|
||||
|
||||
void SwgServerUniverse::updateAndValidateData()
|
||||
{
|
||||
WARNING_STRICT_FATAL(!isAuthoritative(), ("UpdateAndValidateData() should "
|
||||
"only be called on the process that is authoritative for UniverseObjects.\n"));
|
||||
|
||||
// create Jedi manager
|
||||
if (m_jediManager == NULL)
|
||||
{
|
||||
const ServerObjectTemplate * objTemplate = safe_cast<const ServerObjectTemplate *>(ObjectTemplateList::fetch(ConfigServerGame::getJediManagerTemplate()));
|
||||
m_jediManager = safe_cast<JediManagerObject *>(ServerWorld::createNewObject(*objTemplate, Transform::identity, 0, false));
|
||||
NOT_NULL(m_jediManager);
|
||||
registerJediManager(*m_jediManager);
|
||||
m_jediManager->addToWorld();
|
||||
objTemplate->releaseReference();
|
||||
}
|
||||
|
||||
ServerUniverse::updateAndValidateData();
|
||||
}
|
||||
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,62 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// SwgServerUniverse.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_SwgServerUniverse_H
|
||||
#define INCLUDED_SwgServerUniverse_H
|
||||
|
||||
#include "serverGame/ServerUniverse.h"
|
||||
|
||||
class JediManagerObject;
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Singleton that manages Universe objects and functions that are global
|
||||
* to the entire game universe.
|
||||
*/
|
||||
class SwgServerUniverse : public ServerUniverse
|
||||
{
|
||||
public:
|
||||
static void install();
|
||||
|
||||
public:
|
||||
JediManagerObject * getJediManager () const;
|
||||
void registerJediManager(JediManagerObject & jediManager);
|
||||
|
||||
protected:
|
||||
virtual void updateAndValidateData();
|
||||
|
||||
private:
|
||||
JediManagerObject * m_jediManager;
|
||||
|
||||
private:
|
||||
SwgServerUniverse();
|
||||
virtual ~SwgServerUniverse();
|
||||
|
||||
SwgServerUniverse(SwgServerUniverse const &);
|
||||
SwgServerUniverse & operator=(SwgServerUniverse const &);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
inline JediManagerObject * SwgServerUniverse::getJediManager() const
|
||||
{
|
||||
return m_jediManager;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline void SwgServerUniverse::registerJediManager(JediManagerObject & jediManager)
|
||||
{
|
||||
m_jediManager = &jediManager;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,122 @@
|
||||
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "ServerObjectLint.h"
|
||||
|
||||
#include "serverGame/ObjectIdManager.h"
|
||||
#include "serverGame/ServerWorld.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
|
||||
#include "serverGame/ServerArmorTemplate.h"
|
||||
#include "serverGame/ServerBuildingObjectTemplate.h"
|
||||
#include "serverGame/ServerCellObjectTemplate.h"
|
||||
#include "serverGame/ServerCreatureObjectTemplate.h"
|
||||
#include "serverGame/ServerDraftSchematicObjectTemplate.h"
|
||||
#include "serverGame/ServerInstallationObjectTemplate.h"
|
||||
#include "serverGame/ServerMissionObjectTemplate.h"
|
||||
#include "serverGame/ServerManufactureSchematicObjectTemplate.h"
|
||||
#include "serverGame/ServerMissionObjectTemplate.h"
|
||||
#include "serverGame/ServerObject.h"
|
||||
#include "serverGame/ServerObjectTemplate.h"
|
||||
#include "serverGame/ServerPlanetObjectTemplate.h"
|
||||
#include "serverGame/ServerResourceContainerObjectTemplate.h"
|
||||
#include "serverGame/ServerStaticObjectTemplate.h"
|
||||
#include "serverGame/ServerUniverse.h"
|
||||
#include "serverGame/ServerVehicleObjectTemplate.h"
|
||||
#include "serverGame/ServerWeaponObjectTemplate.h"
|
||||
|
||||
#include "sharedGame/SharedBuildingObjectTemplate.h"
|
||||
#include "sharedGame/SharedCellObjectTemplate.h"
|
||||
#include "sharedGame/SharedCreatureObjectTemplate.h"
|
||||
#include "sharedGame/SharedDraftSchematicObjectTemplate.h"
|
||||
#include "sharedGame/SharedInstallationObjectTemplate.h"
|
||||
#include "sharedGame/SharedResourceContainerObjectTemplate.h"
|
||||
#include "sharedGame/SharedStaticObjectTemplate.h"
|
||||
#include "sharedGame/SharedTerrainSurfaceObjectTemplate.h"
|
||||
#include "sharedGame/SharedVehicleObjectTemplate.h"
|
||||
#include "sharedGame/SharedWeaponObjectTemplate.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void ServerObjectLint::install()
|
||||
{
|
||||
ObjectIdManager::getInstance().addBlock(100,10000000); //lint !e747 Significant prototype coercion (arg. no. 1) int to long long
|
||||
}
|
||||
|
||||
void ServerObjectLint::run(const std::vector<std::string> & templateList)
|
||||
{
|
||||
install();
|
||||
|
||||
/*
|
||||
ServerArmorTemplate::install(true);
|
||||
ServerBuildingObjectTemplate::install(true);
|
||||
ServerCellObjectTemplate::install();
|
||||
ServerCreatureObjectTemplate::install(true);
|
||||
ServerDraftSchematicObjectTemplate::install(true);
|
||||
ServerInstallationObjectTemplate::install(true);
|
||||
ServerIntangibleObjectTemplate::install(true);
|
||||
ServerManufactureSchematicObjectTemplate::install(true);
|
||||
ServerMissionBoardObjectTemplate::install(true);
|
||||
ServerMissionObjectTemplate::install(true);
|
||||
ServerObjectTemplate::install(true);
|
||||
ServerPlanetObjectTemplate::install(true);
|
||||
ServerResourceClassObjectTemplate::install(true);
|
||||
ServerResourceContainerObjectTemplate::install(true);
|
||||
ServerResourcePoolObjectTemplate::install(true);
|
||||
ServerResourceTypeObjectTemplate::install(true);
|
||||
ServerStaticObjectTemplate::install(true);
|
||||
ServerTangibleObjectTemplate::install(true);
|
||||
ServerVehicleObjectTemplate::install(true);
|
||||
ServerWeaponObjectTemplate::install(true);
|
||||
|
||||
SharedBuildingObjectTemplate::install(true);
|
||||
SharedCellObjectTemplate::install(true);
|
||||
SharedCreatureObjectTemplate::install(true);
|
||||
SharedDraftSchematicObjectTemplate::install(true);
|
||||
SharedInstallationObjectTemplate::install(true);
|
||||
SharedIntangibleObjectTemplate::install(true);
|
||||
SharedObjectTemplate::install(true);
|
||||
SharedResourceContainerObjectTemplate::install(true);
|
||||
SharedStaticObjectTemplate::install(true);
|
||||
SharedTangibleObjectTemplate::install(true);
|
||||
SharedTerrainSurfaceObjectTemplate::install(true);
|
||||
SharedVehicleObjectTemplate::install(true);
|
||||
SharedWeaponObjectTemplate::install(true);
|
||||
*/
|
||||
ServerWorld::install();
|
||||
|
||||
|
||||
std::vector<std::string>::const_iterator i = templateList.begin();
|
||||
FILE * output = fopen("server_object_lint.sln", "w"); //lint !e64 Type mismatch (initialization) (struct _IO_FILE * = int)
|
||||
FATAL(!output, ("Could not create output file"));
|
||||
for (; i != templateList.end(); ++i)
|
||||
{
|
||||
if (i->find("base") != std::string::npos)
|
||||
{
|
||||
//Don't try to instantiate base templtates
|
||||
IGNORE_RETURN(fprintf(output, "Skipping %s because it is a base class.\n", i->c_str())); //lint !e64 !e119
|
||||
continue;
|
||||
}
|
||||
DEBUG_REPORT_LOG(true, ("Now processing %s...\n", i->c_str()));
|
||||
IGNORE_RETURN(fprintf(output, "Now processing %s...\n", i->c_str()));//lint !e64 !e119
|
||||
IGNORE_RETURN(fflush(output));
|
||||
|
||||
ServerObject* obj = ServerWorld::createObjectFromTemplate((*i), NetworkId(static_cast<NetworkId::NetworkIdType>(1)));
|
||||
DEBUG_REPORT_LOG(!obj, ("***ERROR: Could not create %s\n", i->c_str()));
|
||||
DEBUG_REPORT_LOG(obj,("Successfully created %s\n", i->c_str()));
|
||||
if (!obj)
|
||||
IGNORE_RETURN(fprintf(output, "***ERROR: Could not create %s\n", i->c_str())); //lint !e64 !e119
|
||||
else
|
||||
{
|
||||
IGNORE_RETURN(fprintf(output, "Successfully created %s\n", i->c_str())); //lint !e64 !e119
|
||||
obj->serverObjectInitializeFirstTimeObject(0, Transform::identity);
|
||||
delete obj;
|
||||
obj = 0;
|
||||
}
|
||||
}
|
||||
DEBUG_REPORT_LOG(true, ("-----Done with Server Objects ----\n"));
|
||||
IGNORE_RETURN(fprintf(output, ("-----Done with Server Objects ----\n"))); //lint !e64 !e119
|
||||
IGNORE_RETURN(fclose(output));
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
class ServerObjectLint
|
||||
{
|
||||
public:
|
||||
static void run(const std::vector<std::string> & templateList);
|
||||
static void install();
|
||||
|
||||
private:
|
||||
ServerObjectLint();
|
||||
ServerObjectLint(const ServerObjectLint&);
|
||||
ServerObjectLint& operator= (const ServerObjectLint&);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,111 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// JediManagerObject.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_JediManagerObject_H
|
||||
#define INCLUDED_JediManagerObject_H
|
||||
|
||||
#include "serverGame/UniverseObject.h"
|
||||
#include "swgSharedUtility/JediConstants.h"
|
||||
|
||||
class BountyHunterTargetListMessage;
|
||||
class ScriptParams;
|
||||
class ServerJediManagerObjectTemplate;
|
||||
class Vector;
|
||||
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Keeps track of what Jedi are online and grants bounty missions for them.
|
||||
*/
|
||||
class JediManagerObject : public UniverseObject
|
||||
{
|
||||
public:
|
||||
JediManagerObject(const ServerJediManagerObjectTemplate* newTemplate);
|
||||
virtual ~JediManagerObject();
|
||||
|
||||
void addMembersToPackages();
|
||||
|
||||
virtual void setupUniverse();
|
||||
virtual void onServerUniverseGainedAuthority();
|
||||
virtual Controller* createDefaultController();
|
||||
virtual void conclude();
|
||||
|
||||
void addJedi(const NetworkId & id, const Unicode::String & name, const Vector & location, const std::string & scene, int visibility, int bountyValue, int level, int hoursAlive, int state, int spentJediSkillPoints, int faction);
|
||||
void setJediOffline(const NetworkId & id, const Vector & location, const std::string & scene);
|
||||
void removeJedi(const NetworkId & id);
|
||||
void characterBeingDeleted(const NetworkId & id);
|
||||
void updateJedi(const NetworkId & id, int visibility, int bountyValue, int level, int hoursAlive);
|
||||
void updateJedi(const NetworkId & id, JediState state);
|
||||
// void updateJedi(const NetworkId & id, const std::vector<NetworkId> & bounties) const;
|
||||
void updateJediLocation(const NetworkId & id, const Vector & location, const std::string & scene);
|
||||
void updateJediSpentJediSkillPoints(const NetworkId & id, int spentJediSkillPoints);
|
||||
void updateJediFaction(const NetworkId & id, int faction);
|
||||
void updateJediScriptData(const NetworkId & id, const std::string & name, int value);
|
||||
void removeJediScriptData(const NetworkId & id, const std::string & name);
|
||||
|
||||
void getJedi(int visibility, int bountyValue, int minLevel, int maxLevel, int hoursAlive, int bounties, int state, ScriptParams & returnParams) const;
|
||||
void getJedi(const NetworkId & id, ScriptParams & returnParams) const;
|
||||
bool getJediLocation(const NetworkId & id, Vector & location, std::string & scene) const;
|
||||
void addJediBounties(const BountyHunterTargetListMessage & msg);
|
||||
void requestJediBounty(const NetworkId & targetId, const NetworkId & hunterId, const std::string & successCallback, const std::string & failCallback, const NetworkId & callbackObjectId);
|
||||
void removeJediBounty(const NetworkId & targetId, const NetworkId & hunterId);
|
||||
void removeAllJediBounties(const NetworkId & targetId);
|
||||
const std::vector<NetworkId> & getJediBounties(const NetworkId & targetId) const;
|
||||
void getBountyHunterBounties(const NetworkId & hunterId, std::vector<NetworkId> & jedis) const;
|
||||
|
||||
bool hasBountyOnJedi(const NetworkId & targetId, const NetworkId & hunterId) const;
|
||||
bool hasBountyOnJedi(NetworkId const & hunterId) const;
|
||||
|
||||
static void queueBountyHunterTargetListFromDB(const BountyHunterTargetListMessage * bhtlm);
|
||||
|
||||
protected:
|
||||
virtual void initializeFirstTimeObject();
|
||||
virtual void endBaselines();
|
||||
|
||||
private:
|
||||
JediManagerObject(const JediManagerObject&);
|
||||
JediManagerObject & operator=(const JediManagerObject&);
|
||||
|
||||
void adjustBountyCount(NetworkId const & hunterId, int adjustment);
|
||||
|
||||
private:
|
||||
// most of the jedi information are kept in vectors, which makes it very expensive
|
||||
// to search, so we're going to keep a map to store the index in the vector where
|
||||
// the jedi information is kept; to prevent updating the indices whenever an item is
|
||||
// deleted from the vector, we will never delete items from the vector, but we
|
||||
// will keep track of places in the vector that has been deleted (i.e. the "holes")
|
||||
// so that when a new item is added, we add it to one of the "hole" in the vector
|
||||
Archive::AutoDeltaMap<NetworkId, int> m_jediId;
|
||||
Archive::AutoDeltaVector<int> m_holes;
|
||||
|
||||
Archive::AutoDeltaVector<Unicode::String> m_jediName;
|
||||
Archive::AutoDeltaVector<Vector> m_jediLocation;
|
||||
Archive::AutoDeltaVector<std::string> m_jediScene;
|
||||
Archive::AutoDeltaVector<int> m_jediVisibility;
|
||||
Archive::AutoDeltaVector<int> m_jediBountyValue;
|
||||
Archive::AutoDeltaVector<int> m_jediLevel;
|
||||
Archive::AutoDeltaVector<std::vector<NetworkId> > m_jediBounties; // each element of this vector is a vector of bounty hunters that are chasing the jedi
|
||||
Archive::AutoDeltaMap<NetworkId, int> m_bountyHunters; // map of bounty hunter id --> number of jedis being chased
|
||||
Archive::AutoDeltaVector<int> m_jediHoursAlive;
|
||||
Archive::AutoDeltaVector<int> m_jediState;
|
||||
// this should actuall be a vector of bool, but it won't compile in VC
|
||||
Archive::AutoDeltaVector<int> m_jediOnline;
|
||||
Archive::AutoDeltaVector<int> m_jediSpentJediSkillPoints;
|
||||
Archive::AutoDeltaVector<int> m_jediFaction;
|
||||
Archive::AutoDeltaMap<std::string, int> m_jediScriptData;
|
||||
|
||||
// this contains all the names that are used to make up the key value in m_jediScriptData
|
||||
Archive::AutoDeltaSet<std::string> m_jediScriptDataNames;
|
||||
|
||||
// indicates whether the bounty hunter target list has been received from the DB
|
||||
Archive::AutoDeltaVariable<bool> m_bountyHunterTargetsReceivedFromDB;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,338 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgCreatureObject.cpp
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/SwgCreatureObject.h"
|
||||
#include "serverGame/PlayerCreatureController.h"
|
||||
#include "serverGame/PlayerObject.h"
|
||||
#include "serverGame/ServerCreatureObjectTemplate.h"
|
||||
#include "serverNetworkMessages/MessageToPayload.h"
|
||||
#include "SwgGameServer/JediManagerObject.h"
|
||||
#include "SwgGameServer/SwgPlayerCreatureController.h"
|
||||
#include "SwgGameServer/SwgPlayerObject.h"
|
||||
#include "SwgGameServer/SwgServerUniverse.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
SwgCreatureObject::SwgCreatureObject(const ServerCreatureObjectTemplate* newTemplate) :
|
||||
CreatureObject(newTemplate)
|
||||
{
|
||||
} // SwgCreatureObject::SwgCreatureObject
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
SwgCreatureObject::~SwgCreatureObject()
|
||||
{
|
||||
//-- This must be the first line in the destructor to invalidate any watchers watching this object
|
||||
nullWatchers();
|
||||
|
||||
} // SwgCreatureObject::~SwgCreatureObject
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a default controller for this object.
|
||||
*
|
||||
* @return the object's controller
|
||||
*/
|
||||
Controller* SwgCreatureObject::createDefaultController ()
|
||||
{
|
||||
const ServerCreatureObjectTemplate * myTemplate = safe_cast<
|
||||
const ServerCreatureObjectTemplate *>(getObjectTemplate());
|
||||
|
||||
Controller * controller = 0;
|
||||
if (myTemplate->getCanCreateAvatar())
|
||||
{
|
||||
controller = new SwgPlayerCreatureController(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller = CreatureObject::createDefaultController();
|
||||
}
|
||||
|
||||
setController(controller);
|
||||
return controller;
|
||||
} // CreatureObject::createDefaultController
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Called to alter the creature.
|
||||
*/
|
||||
float SwgCreatureObject::alter(float time)
|
||||
{
|
||||
if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0))
|
||||
{
|
||||
PlayerObject * const player = PlayerCreatureController::getPlayerObject(this);
|
||||
if (player)
|
||||
{
|
||||
SwgPlayerObject * swgPlayer = safe_cast<SwgPlayerObject *>(player);
|
||||
swgPlayer->updateJediLocationTime(time);
|
||||
}
|
||||
}
|
||||
return CreatureObject::alter(time);
|
||||
} // SwgCreatureObject::alter
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Called when the creature is being removed from the world.
|
||||
*/
|
||||
void SwgCreatureObject::onRemovingFromWorld()
|
||||
{
|
||||
// if we are a Jedi, flag ourself as offline
|
||||
if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0))
|
||||
{
|
||||
JediManagerObject * const jediManager = static_cast<SwgServerUniverse &>(ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager != NULL)
|
||||
{
|
||||
jediManager->setJediOffline(getNetworkId(), getPosition_w(), getSceneId());
|
||||
}
|
||||
}
|
||||
|
||||
CreatureObject::onRemovingFromWorld();
|
||||
} // SwgCreatureObject::onRemovingFromWorld
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Called when the creature is being deleted from the game.
|
||||
*/
|
||||
void SwgCreatureObject::onPermanentlyDestroyed()
|
||||
{
|
||||
// if we are a Jedi, remove ourself from the Jedi manager
|
||||
if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0))
|
||||
{
|
||||
JediManagerObject * const jediManager = static_cast<SwgServerUniverse &>(ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager != NULL)
|
||||
{
|
||||
jediManager->removeJedi(getNetworkId());
|
||||
}
|
||||
}
|
||||
|
||||
CreatureObject::onPermanentlyDestroyed();
|
||||
} // SwgCreatureObject::onPermanentlyDestroyed
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Handles messages to this object.
|
||||
*
|
||||
* @param message the message
|
||||
*/
|
||||
void SwgCreatureObject::handleCMessageTo (const MessageToPayload &message)
|
||||
{
|
||||
CreatureObject::handleCMessageTo (message);
|
||||
} // SwgCreatureObject::handleCMessageTo
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks if a player is a Jedi or not.
|
||||
*/
|
||||
bool SwgCreatureObject::isJedi(void) const
|
||||
{
|
||||
if (!isPlayerControlled())
|
||||
return false;
|
||||
|
||||
PlayerObject const * const player = PlayerCreatureController::getPlayerObject(this);
|
||||
if (player)
|
||||
{
|
||||
SwgPlayerObject const * const swgPlayer = safe_cast<SwgPlayerObject const *>(player);
|
||||
return swgPlayer->isJedi();
|
||||
}
|
||||
|
||||
return false;
|
||||
} // SwgCreatureObject::isJedi
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the number of skill points that have been spent on Jedi skills.
|
||||
*/
|
||||
const int SwgCreatureObject::getSpentJediSkillPoints() const
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
/* skill points no longer exist
|
||||
const SkillList & skills = getSkillList();
|
||||
for (SkillList::const_iterator i = skills.begin(); i != skills.end(); ++i)
|
||||
{
|
||||
if (*i)
|
||||
{
|
||||
// per Dave White, we only care about skills starting with "force_discipline"
|
||||
if ((*i)->getSkillName().find("force_discipline") == 0)
|
||||
result += (*i)->getSkillPointCost();
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING(true, ("Creature %s had a null in their skill list", getNetworkId().getValueString().c_str()));
|
||||
}
|
||||
}
|
||||
*/
|
||||
return result;
|
||||
} // SwgCreatureObject::getSpentJediSkillPoints
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Tests if this creature has a bounty on another creature.
|
||||
*
|
||||
* @param target the creature to test if we have a bounty on
|
||||
*
|
||||
* @return true if we have a bounty on the target, false if not
|
||||
*/
|
||||
bool SwgCreatureObject::hasBounty(const CreatureObject & target) const
|
||||
{
|
||||
const SwgCreatureObject * swgTarget = dynamic_cast<const SwgCreatureObject *>(
|
||||
&target);
|
||||
if (swgTarget == NULL)
|
||||
return false;
|
||||
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(
|
||||
ServerUniverse::getInstance()).getJediManager();
|
||||
NOT_NULL(jediManager);
|
||||
|
||||
return jediManager->hasBountyOnJedi(target.getNetworkId(), getNetworkId());
|
||||
} // SwgCreatureObject::hasBounty
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Tests if this creature has a bounty on any other creature.
|
||||
*
|
||||
* @return true if we have a bounty, false if not
|
||||
*/
|
||||
bool SwgCreatureObject::hasBounty() const
|
||||
{
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(
|
||||
ServerUniverse::getInstance()).getJediManager();
|
||||
NOT_NULL(jediManager);
|
||||
|
||||
return jediManager->hasBountyOnJedi(getNetworkId());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
std::vector<NetworkId> const & SwgCreatureObject::getJediBountiesOnMe() const
|
||||
{
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(
|
||||
ServerUniverse::getInstance()).getJediManager();
|
||||
NOT_NULL(jediManager);
|
||||
|
||||
return jediManager->getJediBounties(getNetworkId());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int SwgCreatureObject::getBountyValue() const
|
||||
{
|
||||
int bountyValue;
|
||||
if (getObjVars().getItem("bounty.amount", bountyValue))
|
||||
return bountyValue;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
const bool SwgCreatureObject::grantSkill(const SkillObject & newSkill)
|
||||
{
|
||||
return CreatureObject::grantSkill(newSkill);
|
||||
} // SwgCreatureObject::grantSkill
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void SwgCreatureObject::revokeSkill(const SkillObject & oldSkill)
|
||||
{
|
||||
CreatureObject::revokeSkill(oldSkill);
|
||||
} // SwgCreatureObject::revokeSkill
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void SwgCreatureObject::endBaselines()
|
||||
{
|
||||
CreatureObject::endBaselines();
|
||||
|
||||
// if the player has a bounty value, register him with the bounty manager
|
||||
if (isAuthoritative() && isPlayerControlled())
|
||||
{
|
||||
int bountyValue = getBountyValue();
|
||||
if (bountyValue > 0)
|
||||
{
|
||||
SwgPlayerObject const * player = safe_cast<SwgPlayerObject const *>(PlayerCreatureController::getPlayerObject(this));
|
||||
if (player)
|
||||
{
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager)
|
||||
{
|
||||
jediManager->addJedi(getNetworkId(), getObjectName(),
|
||||
getPosition_w(), getSceneId(), player->getJediVisibility(),
|
||||
bountyValue, getLevel(),
|
||||
0, player->getJediState(), getSpentJediSkillPoints(), getPvpFaction());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void SwgCreatureObject::onAddedToWorld()
|
||||
{
|
||||
CreatureObject::onAddedToWorld();
|
||||
if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0))
|
||||
{
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager != NULL)
|
||||
{
|
||||
jediManager->updateJediLocation(getNetworkId(), getPosition_w(), getSceneId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void SwgCreatureObject::levelChanged() const
|
||||
{
|
||||
CreatureObject::levelChanged();
|
||||
|
||||
// If the player has a bounty value, update the level with the bounty manager
|
||||
if (isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0))
|
||||
{
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager)
|
||||
{
|
||||
jediManager->updateJedi(getNetworkId(), -1, -1, getLevel(), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
void SwgCreatureObject::setPvpFaction(Pvp::FactionId factionId)
|
||||
{
|
||||
Pvp::FactionId oldId = getPvpFaction();
|
||||
CreatureObject::setPvpFaction(factionId);
|
||||
Pvp::FactionId newId = getPvpFaction();
|
||||
if ((oldId != newId) && isAuthoritative() && isPlayerControlled() && (getBountyValue() > 0))
|
||||
{
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager != NULL)
|
||||
{
|
||||
jediManager->updateJediFaction(getNetworkId(), newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgCreatureObject.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef INCLUDED_SwgCreatureObject_H
|
||||
#define INCLUDED_SwgCreatureObject_H
|
||||
|
||||
#include "serverGame/CreatureObject.h"
|
||||
|
||||
|
||||
class ServerCreatureObjectTemplate;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class SwgCreatureObject : public CreatureObject
|
||||
{
|
||||
public:
|
||||
explicit SwgCreatureObject(const ServerCreatureObjectTemplate * newTemplate);
|
||||
virtual ~SwgCreatureObject();
|
||||
|
||||
virtual void handleCMessageTo (const MessageToPayload &message);
|
||||
|
||||
bool isJedi(void) const;
|
||||
const int getSpentJediSkillPoints() const;
|
||||
|
||||
virtual Controller* createDefaultController();
|
||||
virtual float alter(float time);
|
||||
virtual void onRemovingFromWorld();
|
||||
virtual void onPermanentlyDestroyed();
|
||||
|
||||
virtual bool hasBounty(const CreatureObject & target) const;
|
||||
virtual bool hasBounty() const;
|
||||
virtual std::vector<NetworkId> const & getJediBountiesOnMe() const;
|
||||
int getBountyValue() const;
|
||||
|
||||
virtual const bool grantSkill(const SkillObject & newSkill);
|
||||
virtual void revokeSkill(const SkillObject & oldSkill);
|
||||
|
||||
virtual void setPvpFaction(Pvp::FactionId factionId);
|
||||
|
||||
protected:
|
||||
virtual void endBaselines();
|
||||
virtual void onAddedToWorld();
|
||||
virtual void levelChanged() const;
|
||||
|
||||
private:
|
||||
SwgCreatureObject();
|
||||
SwgCreatureObject(const SwgCreatureObject& rhs);
|
||||
SwgCreatureObject& operator=(const SwgCreatureObject& rhs);
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // INCLUDED_SwgCreatureObject_H
|
||||
@@ -0,0 +1,374 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgCreatureObject.cpp
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/SwgCreatureObject.h"
|
||||
#include "SwgGameServer/SwgPlayerObject.h"
|
||||
#include "serverGame/ConfigServerGame.h"
|
||||
#include "serverGame/CreatureObject.h"
|
||||
#include "serverGame/PlayerObject.h"
|
||||
#include "serverNetworkMessages/MessageToPayload.h"
|
||||
#include "sharedFoundation/DynamicVariableList.h"
|
||||
#include "sharedNetworkMessages/MessageQueueGenericValueType.h"
|
||||
#include "SwgGameServer/JediManagerObject.h"
|
||||
#include "SwgGameServer/SwgServerUniverse.h"
|
||||
#include "serverGame/PlayerCreatureController.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// jedi/force power objvars
|
||||
const static std::string OBJVAR_JEDI("jedi");
|
||||
const static std::string OBJVAR_JEDI_STATE("jedi.state");
|
||||
const static std::string OBJVAR_FORCE_REGEN_RATE("jedi.regenrate");
|
||||
const static std::string OBJVAR_FORCE_REGEN_VALUE("jedi.regenvalue");
|
||||
const static std::string OBJVAR_JEDI_VISIBILITY("jedi.visibility");
|
||||
const static std::string OBJVAR_JEDI_BOUNTIES("jedi.objKillers");
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
SwgPlayerObject::SwgPlayerObject(const ServerPlayerObjectTemplate* newTemplate) :
|
||||
PlayerObject(newTemplate),
|
||||
m_updateJediLocationTime(0),
|
||||
m_jediState(0)
|
||||
{
|
||||
addMembersToPackages();
|
||||
} // SwgCreatureObject::SwgCreatureObject
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
SwgPlayerObject::~SwgPlayerObject()
|
||||
{
|
||||
} // SwgPlayerObject::~SwgPlayerObject
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets up auto-sync data.
|
||||
*/
|
||||
void SwgPlayerObject::addMembersToPackages()
|
||||
{
|
||||
//@todo: do we want to make a game equivalent of package.txt and Packager.cpp?
|
||||
addFirstParentAuthClientServerVariable_np (m_jediState);
|
||||
} // SwgPlayerObject::addMembersToPackages
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Initializes data for a proxy object.
|
||||
*/
|
||||
void SwgPlayerObject::endBaselines()
|
||||
{
|
||||
PlayerObject::endBaselines();
|
||||
|
||||
if (isAuthoritative())
|
||||
{
|
||||
// get the jediState from the objvar
|
||||
int jediState = 0;
|
||||
if (getObjVars().getItem(OBJVAR_JEDI_STATE, jediState))
|
||||
m_jediState = static_cast<JediState>(jediState);
|
||||
}
|
||||
} // SwgPlayerObject::endBaselines
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Called when we are made authoritative.
|
||||
*/
|
||||
void SwgPlayerObject::virtualOnSetAuthority()
|
||||
{
|
||||
PlayerObject::virtualOnSetAuthority();
|
||||
|
||||
const SwgCreatureObject * owner = safe_cast<const SwgCreatureObject *>(getCreatureObject());
|
||||
if ((owner != NULL) && owner->isPlayerControlled() && (owner->getBountyValue() > 0))
|
||||
{
|
||||
// tell the Jedi manager our position
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(
|
||||
ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager != NULL)
|
||||
{
|
||||
jediManager->updateJediLocation(owner->getNetworkId(),
|
||||
owner->getPosition_w(), owner->getSceneId());
|
||||
}
|
||||
m_updateJediLocationTime = 0;
|
||||
}
|
||||
} // SwgPlayerObject::virtualOnSetAuthority
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets the Jedi state for the player.
|
||||
*
|
||||
* @param state the new state
|
||||
*/
|
||||
void SwgPlayerObject::setJediState(JediState state)
|
||||
{
|
||||
if (state == JS_none ||
|
||||
state == JS_forceSensitive ||
|
||||
state == JS_jedi ||
|
||||
state == JS_forceRankedLight ||
|
||||
state == JS_forceRankedDark
|
||||
)
|
||||
{
|
||||
if (isAuthoritative())
|
||||
{
|
||||
// get our current state for comparison
|
||||
JediState oldState = getJediState();
|
||||
bool oldIsJedi = isJedi();
|
||||
|
||||
m_jediState = state;
|
||||
if (state == JS_none)
|
||||
{
|
||||
if (oldState != JS_none)
|
||||
{
|
||||
// we are no longer force sensitive
|
||||
removeObjVarItem(OBJVAR_JEDI);
|
||||
setMaxForcePower(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVarItem(OBJVAR_JEDI_STATE, state);
|
||||
if (oldState == JS_none)
|
||||
{
|
||||
// we are newly force sensitive
|
||||
// note that our max force power needs to be set separately
|
||||
WARNING(getForcePowerRegenRate() > 0, ("SwgPlayerObject::setJediState, "
|
||||
"resetting force power regen for player %s that has a non-zero "
|
||||
"regen value %f", getAccountDescription(getCreatureObject()).c_str(),
|
||||
getForcePowerRegenRate()));
|
||||
setForcePowerRegenRate(ConfigServerGame::getMinForcePowerRegenRate());
|
||||
}
|
||||
}
|
||||
|
||||
// check if our Jedi status has turned on or off
|
||||
if (!oldIsJedi && isJedi())
|
||||
{
|
||||
setJediVisibility(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendControllerMessageToAuthServer(CM_setJediState,
|
||||
new MessageQueueGenericValueType<int>(static_cast<int>(state)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING(true, ("setJediState for player %s invalid state %d",
|
||||
getAccountDescription(getCreatureObject()).c_str(), state));
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Updates the time from when we sent the Jedi manager our position.
|
||||
*
|
||||
* @param time time since the last call
|
||||
*/
|
||||
void SwgPlayerObject::updateJediLocationTime(float time)
|
||||
{
|
||||
if (isAuthoritative())
|
||||
{
|
||||
m_updateJediLocationTime += time;
|
||||
if (m_updateJediLocationTime > static_cast<float>(
|
||||
ConfigServerGame::getJediUpdateLocationTimeSeconds()))
|
||||
{
|
||||
m_updateJediLocationTime = 0;
|
||||
|
||||
// tell the Jedi manager our position
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(
|
||||
ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager != NULL)
|
||||
{
|
||||
const CreatureObject * owner = getCreatureObject();
|
||||
if (owner->isInWorld())
|
||||
{
|
||||
jediManager->updateJediLocation(owner->getNetworkId(),
|
||||
owner->getPosition_w(), owner->getSceneId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // SwgPlayerObject::updateJediLocationTime
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets the visibility of a Jedi.
|
||||
*
|
||||
* @param visibility the visibility value
|
||||
*/
|
||||
void SwgPlayerObject::setJediVisibility(int visibility)
|
||||
{
|
||||
if (!isJedi())
|
||||
return;
|
||||
|
||||
if (visibility < 0)
|
||||
visibility = 0;
|
||||
|
||||
setObjVarItem(OBJVAR_JEDI_VISIBILITY, visibility);
|
||||
} // SwgPlayerObject::setJediVisibility
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the visibility of a Jedi.
|
||||
*
|
||||
* @return the visibility of the Jedi
|
||||
*/
|
||||
int SwgPlayerObject::getJediVisibility(void) const
|
||||
{
|
||||
if (!isJedi())
|
||||
return 0;
|
||||
|
||||
int visibility;
|
||||
if (!getObjVars().getItem(OBJVAR_JEDI_VISIBILITY,visibility))
|
||||
{
|
||||
WARNING(true, ("Jedi %s doesn't have a visibility objvar, adding one",
|
||||
getNetworkId().getValueString().c_str()));
|
||||
const_cast<SwgPlayerObject *>(this)->setJediVisibility(0);
|
||||
return 0;
|
||||
}
|
||||
return visibility;
|
||||
} // SwgPlayerObject::getJediVisibility
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Adds a bounty hunter to the list of players hunting this Jedi.
|
||||
*
|
||||
* @param hunter the bounty hunter's id
|
||||
*/
|
||||
/*
|
||||
void SwgPlayerObject::addJediBounty(const NetworkId & hunter)
|
||||
{
|
||||
if (!isJedi())
|
||||
return;
|
||||
|
||||
std::vector<NetworkId> bounties;
|
||||
if (getObjVars().getItem(OBJVAR_JEDI_BOUNTIES, bounties))
|
||||
{
|
||||
// make sure we don't have the hunter already on our list
|
||||
if (std::find(bounties.begin(), bounties.end(), hunter) == bounties.end())
|
||||
{
|
||||
bounties.push_back(hunter);
|
||||
setObjVarItem(OBJVAR_JEDI_BOUNTIES, bounties);
|
||||
}
|
||||
}
|
||||
|
||||
// note that since this function should only be called due to the Jedi
|
||||
// manager being updated, so we don't forward this to the manager like
|
||||
// we do with setJediBounties
|
||||
} // SwgPlayerObject::addJediBounty
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Removes a bounty hunter from the list of players hunting this Jedi.
|
||||
*
|
||||
* @param hunter the bounty hunter's id
|
||||
*/
|
||||
/*
|
||||
void SwgPlayerObject::removeJediBounty(const NetworkId & hunter)
|
||||
{
|
||||
if (!isJedi())
|
||||
return;
|
||||
|
||||
std::vector<NetworkId> bounties;
|
||||
if (getObjVars().getItem(OBJVAR_JEDI_BOUNTIES, bounties))
|
||||
{
|
||||
std::vector<NetworkId>::iterator i = std::find(bounties.begin(),
|
||||
bounties.end(), hunter);
|
||||
if (i != bounties.end())
|
||||
{
|
||||
bounties.erase(i);
|
||||
setObjVarItem(OBJVAR_JEDI_BOUNTIES, bounties);
|
||||
}
|
||||
}
|
||||
|
||||
// note that since this function should only be called due to the Jedi
|
||||
// manager being updated, so we don't forward this to the manager like
|
||||
// we do with setJediBounties
|
||||
} // SwgPlayerObject::removeJediBounty
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets the bounties on a Jedi.
|
||||
*
|
||||
* @param bounties the number of bounties
|
||||
*
|
||||
void SwgPlayerObject::setJediBounties(const std::vector<NetworkId> & bounties)
|
||||
{
|
||||
if (!isJedi())
|
||||
return;
|
||||
|
||||
setObjVarItem(OBJVAR_JEDI_BOUNTIES, bounties);
|
||||
|
||||
// update the Jedi manager
|
||||
JediManagerObject * jediManager = static_cast<SwgServerUniverse &>(
|
||||
ServerUniverse::getInstance()).getJediManager();
|
||||
if (jediManager != NULL)
|
||||
{
|
||||
const CreatureObject * owner = getCreatureObject();
|
||||
jediManager->updateJedi(owner->getNetworkId(), bounties);
|
||||
}
|
||||
} // SwgPlayerObject::setJediBounties
|
||||
*/
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the bounties on a Jedi once for old characters. Once this function is
|
||||
* called for a player, assume the Jedi manager is authoritative for who
|
||||
* has bounties on this Jedi.
|
||||
*
|
||||
* @param bounties vector to be filled in with the ids of the players
|
||||
* hunting the Jedi
|
||||
*
|
||||
* @return true if bounties has good data, false if not
|
||||
*/
|
||||
/*
|
||||
bool SwgPlayerObject::getJediBounties(std::vector<NetworkId> & bounties)
|
||||
{
|
||||
if (!isJedi())
|
||||
return false;
|
||||
|
||||
bounties.clear();
|
||||
SwgCreatureObject * owner = safe_cast<SwgCreatureObject *>(getCreatureObject());
|
||||
if (owner != NULL)
|
||||
{
|
||||
if (owner->getObjVars().getItem(OBJVAR_JEDI_BOUNTIES, bounties))
|
||||
{
|
||||
// remove the objvar, the Jedi manager is authoritative for this data
|
||||
owner->removeObjVarItem(OBJVAR_JEDI_BOUNTIES);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} // SwgPlayerObject::getJediBounties
|
||||
*/
|
||||
/**
|
||||
* Calculates whether a player is a jedi
|
||||
*
|
||||
* @return true if the player is a jedi
|
||||
*/
|
||||
bool SwgPlayerObject::isJedi() const
|
||||
{
|
||||
return (getJediState() & (JS_jedi | JS_forceRankedLight | JS_forceRankedDark)) != 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgPlayerObject.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef INCLUDED_SwgPlayerObject_H
|
||||
#define INCLUDED_SwgPlayerObject_H
|
||||
|
||||
#include "serverGame/PlayerObject.h"
|
||||
#include "swgSharedUtility/JediConstants.h"
|
||||
|
||||
class ServerPlayerObjectTemplate;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class SwgPlayerObject : public PlayerObject
|
||||
{
|
||||
public:
|
||||
explicit SwgPlayerObject(const ServerPlayerObjectTemplate * newTemplate);
|
||||
virtual ~SwgPlayerObject();
|
||||
|
||||
// Jedi functions
|
||||
virtual bool isJedi(void) const;
|
||||
JediState getJediState() const;
|
||||
void setJediState(JediState state);
|
||||
void updateJediLocationTime(float time);
|
||||
void setJediVisibility(int visibility);
|
||||
int getJediVisibility(void) const;
|
||||
// void addJediBounty(const NetworkId & hunter);
|
||||
// void removeJediBounty(const NetworkId & hunter);
|
||||
// void setJediBounties(const std::vector<NetworkId> & bounties);
|
||||
// bool getJediBounties(std::vector<NetworkId> & bounties);
|
||||
|
||||
protected:
|
||||
virtual void endBaselines();
|
||||
virtual void virtualOnSetAuthority();
|
||||
|
||||
private:
|
||||
void addMembersToPackages();
|
||||
|
||||
// bool getJediBounties(std::vector<NetworkId> & bounties);
|
||||
|
||||
private:
|
||||
SwgPlayerObject();
|
||||
SwgPlayerObject(const SwgPlayerObject & rhs);
|
||||
SwgPlayerObject & operator=(const SwgPlayerObject & rhs);
|
||||
|
||||
private:
|
||||
float m_updateJediLocationTime;
|
||||
Archive::AutoDeltaVariable<int> m_jediState;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
inline JediState SwgPlayerObject::getJediState() const
|
||||
{
|
||||
return static_cast<JediState>(m_jediState.get());
|
||||
}
|
||||
|
||||
|
||||
#endif // INCLUDED_SwgPlayerObject_H
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerJediManagerObjectTemplate.cpp
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "ServerJediManagerObjectTemplate.h"
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedFile/Iff.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
#include "SwgGameServer/JediManagerObject.h"
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
#include <stdio.h>
|
||||
|
||||
const std::string DefaultString("");
|
||||
const StringId DefaultStringId("", 0);
|
||||
const Vector DefaultVector(0,0,0);
|
||||
const TriggerVolumeData DefaultTriggerVolumeData;
|
||||
|
||||
bool ServerJediManagerObjectTemplate::ms_allowDefaultTemplateParams = true;
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
ServerJediManagerObjectTemplate::ServerJediManagerObjectTemplate(const std::string & filename)
|
||||
//@BEGIN TFD INIT
|
||||
: ServerUniverseObjectTemplate(filename)
|
||||
,m_versionOk(true)
|
||||
//@END TFD INIT
|
||||
{
|
||||
} // ServerJediManagerObjectTemplate::ServerJediManagerObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
ServerJediManagerObjectTemplate::~ServerJediManagerObjectTemplate()
|
||||
{
|
||||
//@BEGIN TFD CLEANUP
|
||||
//@END TFD CLEANUP
|
||||
} // ServerJediManagerObjectTemplate::~ServerJediManagerObjectTemplate
|
||||
|
||||
/**
|
||||
* Static function used to register this template.
|
||||
*/
|
||||
void ServerJediManagerObjectTemplate::registerMe(void)
|
||||
{
|
||||
ObjectTemplateList::registerTemplate(ServerJediManagerObjectTemplate_tag, create);
|
||||
} // ServerJediManagerObjectTemplate::registerMe
|
||||
|
||||
/**
|
||||
* Creates a ServerJediManagerObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * ServerJediManagerObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new ServerJediManagerObjectTemplate(filename);
|
||||
} // ServerJediManagerObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Returns the template id.
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
Tag ServerJediManagerObjectTemplate::getId(void) const
|
||||
{
|
||||
return ServerJediManagerObjectTemplate_tag;
|
||||
} // ServerJediManagerObjectTemplate::getId
|
||||
|
||||
/**
|
||||
* Returns this template's version.
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
Tag ServerJediManagerObjectTemplate::getTemplateVersion(void) const
|
||||
{
|
||||
return m_templateVersion;
|
||||
} // ServerJediManagerObjectTemplate::getTemplateVersion
|
||||
|
||||
/**
|
||||
* Returns the highest version of this template or it's base templates.
|
||||
*
|
||||
* @return the highest version
|
||||
*/
|
||||
Tag ServerJediManagerObjectTemplate::getHighestTemplateVersion(void) const
|
||||
{
|
||||
if (m_baseData == NULL)
|
||||
return m_templateVersion;
|
||||
const ServerJediManagerObjectTemplate * base = dynamic_cast<const ServerJediManagerObjectTemplate *>(m_baseData);
|
||||
if (base == NULL)
|
||||
return m_templateVersion;
|
||||
return std::max(m_templateVersion, base->getHighestTemplateVersion());
|
||||
} // ServerJediManagerObjectTemplate::getHighestTemplateVersion
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * ServerJediManagerObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new JediManagerObject(this);
|
||||
} // ServerJediManagerObjectTemplate::createObject
|
||||
|
||||
//@BEGIN TFD
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* Special function used by datalint. Checks for duplicate values in base and derived templates.
|
||||
*/
|
||||
void ServerJediManagerObjectTemplate::testValues(void) const
|
||||
{
|
||||
ServerUniverseObjectTemplate::testValues();
|
||||
} // ServerJediManagerObjectTemplate::testValues
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Loads the template data from an iff file. We should already be in the form
|
||||
* for this template.
|
||||
*
|
||||
* @param file file to load from
|
||||
*/
|
||||
void ServerJediManagerObjectTemplate::load(Iff &file)
|
||||
{
|
||||
static const int MAX_NAME_SIZE = 256;
|
||||
char paramName[MAX_NAME_SIZE];
|
||||
|
||||
if (file.getCurrentName() != ServerJediManagerObjectTemplate_tag)
|
||||
{
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
return;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
if (m_templateVersion == TAG(D,E,R,V))
|
||||
{
|
||||
file.enterForm();
|
||||
file.enterChunk();
|
||||
std::string baseFilename;
|
||||
file.read_string(baseFilename);
|
||||
file.exitChunk();
|
||||
const ObjectTemplate *base = ObjectTemplateList::fetch(baseFilename);
|
||||
DEBUG_WARNING(base == NULL, ("was unable to load base template %s", baseFilename.c_str()));
|
||||
if (m_baseData == base && base != NULL)
|
||||
base->releaseReference();
|
||||
else
|
||||
{
|
||||
if (m_baseData != NULL)
|
||||
m_baseData->releaseReference();
|
||||
m_baseData = base;
|
||||
}
|
||||
file.exitForm();
|
||||
m_templateVersion = file.getCurrentName();
|
||||
}
|
||||
if (getHighestTemplateVersion() != TAG(0,0,0,0))
|
||||
{
|
||||
if (DataLint::isEnabled())
|
||||
DEBUG_WARNING(true, ("template %s version out of date", file.getFileName()));
|
||||
m_versionOk = false;
|
||||
}
|
||||
|
||||
file.enterForm();
|
||||
|
||||
file.enterChunk();
|
||||
int paramCount = file.read_int32();
|
||||
file.exitChunk();
|
||||
UNREF(paramName);
|
||||
UNREF(paramCount);
|
||||
|
||||
file.exitForm();
|
||||
ServerUniverseObjectTemplate::load(file);
|
||||
file.exitForm();
|
||||
return;
|
||||
} // ServerJediManagerObjectTemplate::load
|
||||
|
||||
//@END TFD
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//========================================================================
|
||||
//
|
||||
// ServerJediManagerObjectTemplate.h
|
||||
//
|
||||
//IMPORTANT: Any code between //@BEGIN TFD... and //@END TFD... will be
|
||||
//overwritten the next time the template definition is compiled. Do not
|
||||
//make changes to code inside these blocks.
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_ServerJediManagerObjectTemplate_H
|
||||
#define _INCLUDED_ServerJediManagerObjectTemplate_H
|
||||
|
||||
#include "serverGame/ServerUniverseObjectTemplate.h"
|
||||
#include "sharedFoundation/DynamicVariable.h"
|
||||
#include "sharedUtility/TemplateParameter.h"
|
||||
|
||||
|
||||
class Vector;
|
||||
typedef StructParam<ObjectTemplate> StructParamOT;
|
||||
//@BEGIN TFD TEMPLATE REFS
|
||||
//@END TFD TEMPLATE REFS
|
||||
|
||||
|
||||
class ServerJediManagerObjectTemplate : public ServerUniverseObjectTemplate
|
||||
{
|
||||
public:
|
||||
//@BEGIN TFD ID
|
||||
enum
|
||||
{
|
||||
ServerJediManagerObjectTemplate_tag = TAG(J,E,D,I)
|
||||
};
|
||||
//@END TFD ID
|
||||
public:
|
||||
ServerJediManagerObjectTemplate(const std::string & filename);
|
||||
virtual ~ServerJediManagerObjectTemplate();
|
||||
|
||||
virtual Tag getId(void) const;
|
||||
virtual Tag getTemplateVersion(void) const;
|
||||
virtual Tag getHighestTemplateVersion(void) const;
|
||||
static void install(bool allowDefaultTemplateParams = true);
|
||||
|
||||
//@BEGIN TFD
|
||||
public:
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
// special code used by datalint
|
||||
virtual void testValues(void) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void load(Iff &file);
|
||||
|
||||
private:
|
||||
//@END TFD
|
||||
|
||||
public:
|
||||
// user functions
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
Tag m_templateVersion; // the template version
|
||||
bool m_versionOk; // flag that the template version loaded is the one we expect
|
||||
static bool ms_allowDefaultTemplateParams; // flag to allow defaut params instead of fataling
|
||||
|
||||
static void registerMe(void);
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
ServerJediManagerObjectTemplate(const ServerJediManagerObjectTemplate &);
|
||||
ServerJediManagerObjectTemplate & operator =(const ServerJediManagerObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
inline void ServerJediManagerObjectTemplate::install(bool allowDefaultTemplateParams)
|
||||
{
|
||||
ms_allowDefaultTemplateParams = allowDefaultTemplateParams;
|
||||
//@BEGIN TFD INSTALL
|
||||
ServerJediManagerObjectTemplate::registerMe();
|
||||
//@END TFD INSTALL
|
||||
}
|
||||
|
||||
|
||||
#endif // _INCLUDED_ServerJediManagerObjectTemplate_H
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgServerCreatureObjectTemplate.cpp
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/SwgServerCreatureObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
#include "SwgGameServer/SwgCreatureObject.h"
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
SwgServerCreatureObjectTemplate::SwgServerCreatureObjectTemplate(const std::string & filename) :
|
||||
ServerCreatureObjectTemplate(filename)
|
||||
{
|
||||
} // SwgServerCreatureObjectTemplate::SwgServerCreatureObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
SwgServerCreatureObjectTemplate::~SwgServerCreatureObjectTemplate()
|
||||
{
|
||||
} // SwgServerCreatureObjectTemplate::~SwgServerCreatureObjectTemplate
|
||||
|
||||
/**
|
||||
* Replaces the ServerCreatureObjectTemplate tag->create mapping with our own.
|
||||
*/
|
||||
void SwgServerCreatureObjectTemplate::install(void)
|
||||
{
|
||||
ObjectTemplateList::assignBinding(ServerCreatureObjectTemplate_tag, create);
|
||||
} // SwgServerCreatureObjectTemplate::install
|
||||
|
||||
/**
|
||||
* Creates a SwgServerCreatureObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * SwgServerCreatureObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new SwgServerCreatureObjectTemplate(filename);
|
||||
} // SwgServerCreatureObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * SwgServerCreatureObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new SwgCreatureObject(this);
|
||||
} // SwgServerCreatureObjectTemplate::createObject
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgServerCreatureObjectTemplate.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_SwgServerCreatureObjectTemplate_H
|
||||
#define _INCLUDED_SwgServerCreatureObjectTemplate_H
|
||||
|
||||
#include "serverGame/ServerCreatureObjectTemplate.h"
|
||||
|
||||
|
||||
class SwgServerCreatureObjectTemplate : public ServerCreatureObjectTemplate
|
||||
{
|
||||
public:
|
||||
SwgServerCreatureObjectTemplate(const std::string & filename);
|
||||
virtual ~SwgServerCreatureObjectTemplate();
|
||||
|
||||
static void install(void);
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
SwgServerCreatureObjectTemplate(const SwgServerCreatureObjectTemplate &);
|
||||
SwgServerCreatureObjectTemplate & operator =(const SwgServerCreatureObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
#endif // _INCLUDED_SwgServerCreatureObjectTemplate_H
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgServerPlayerObjectTemplate.cpp
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/SwgServerPlayerObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
#include "SwgGameServer/SwgPlayerObject.h"
|
||||
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
SwgServerPlayerObjectTemplate::SwgServerPlayerObjectTemplate(const std::string & filename) :
|
||||
ServerPlayerObjectTemplate(filename)
|
||||
{
|
||||
} // SwgServerPlayerObjectTemplate::SwgServerPlayerObjectTemplate
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
SwgServerPlayerObjectTemplate::~SwgServerPlayerObjectTemplate()
|
||||
{
|
||||
} // SwgServerPlayerObjectTemplate::~SwgServerPlayerObjectTemplate
|
||||
|
||||
/**
|
||||
* Replaces the ServerCreatureObjectTemplate tag->create mapping with our own.
|
||||
*/
|
||||
void SwgServerPlayerObjectTemplate::install(void)
|
||||
{
|
||||
ObjectTemplateList::assignBinding(ServerPlayerObjectTemplate_tag, create);
|
||||
} // SwgServerPlayerObjectTemplate::install
|
||||
|
||||
/**
|
||||
* Creates a SwgServerPlayerObjectTemplate template.
|
||||
*
|
||||
* @return a new instance of the template
|
||||
*/
|
||||
ObjectTemplate * SwgServerPlayerObjectTemplate::create(const std::string & filename)
|
||||
{
|
||||
return new SwgServerPlayerObjectTemplate(filename);
|
||||
} // SwgServerPlayerObjectTemplate::create
|
||||
|
||||
/**
|
||||
* Creates a new object from this template.
|
||||
*
|
||||
* @return the object
|
||||
*/
|
||||
Object * SwgServerPlayerObjectTemplate::createObject(void) const
|
||||
{
|
||||
return new SwgPlayerObject(this);
|
||||
} // SwgServerPlayerObjectTemplate::createObject
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
//========================================================================
|
||||
//
|
||||
// SwgServerPlayerObjectTemplate.h
|
||||
//
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _INCLUDED_SwgServerPlayerObjectTemplate_H
|
||||
#define _INCLUDED_SwgServerPlayerObjectTemplate_H
|
||||
|
||||
#include "serverGame/ServerPlayerObjectTemplate.h"
|
||||
|
||||
|
||||
class SwgServerPlayerObjectTemplate : public ServerPlayerObjectTemplate
|
||||
{
|
||||
public:
|
||||
SwgServerPlayerObjectTemplate(const std::string & filename);
|
||||
virtual ~SwgServerPlayerObjectTemplate();
|
||||
|
||||
static void install(void);
|
||||
virtual Object * createObject(void) const;
|
||||
|
||||
private:
|
||||
static ObjectTemplate * create(const std::string & filename);
|
||||
|
||||
// no copying
|
||||
SwgServerPlayerObjectTemplate(const SwgServerPlayerObjectTemplate &);
|
||||
SwgServerPlayerObjectTemplate & operator =(const SwgServerPlayerObjectTemplate &);
|
||||
};
|
||||
|
||||
|
||||
#endif // _INCLUDED_SwgServerPlayerObjectTemplate_H
|
||||
@@ -0,0 +1,366 @@
|
||||
//===================================================================
|
||||
//
|
||||
// WorldSnapshotParser.cpp
|
||||
// asommers
|
||||
//
|
||||
// copyright 2002, sony online entertainment
|
||||
//
|
||||
//===================================================================
|
||||
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "SwgGameServer/WorldSnapshotParser.h"
|
||||
|
||||
#include "serverGame/ServerBuildingObjectTemplate.h"
|
||||
#include "serverGame/ServerCellObjectTemplate.h"
|
||||
#include "serverGame/ServerObjectTemplate.h"
|
||||
#include "serverGame/ServerStaticObjectTemplate.h"
|
||||
#include "serverGame/ServerTangibleObjectTemplate.h"
|
||||
#include "serverGame/ServerWorld.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFoundation/ConstCharCrcString.h"
|
||||
#include "sharedFoundation/PointerDeleter.h"
|
||||
#include "sharedGame/SharedObjectTemplate.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
#include "sharedObject/PortalPropertyTemplate.h"
|
||||
#include "sharedUtility/WorldSnapshotReaderWriter.h"
|
||||
#include "sharedMath/Quaternion.h"
|
||||
#include "sharedMath/Transform.h"
|
||||
#include "sharedMath/Vector.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
//===================================================================
|
||||
|
||||
namespace
|
||||
{
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
const char* const ms_serverCellObjectTemplateName = "object/cell/cell.iff";
|
||||
|
||||
typedef std::map<std::string, WorldSnapshotReaderWriter*> PlanetMap;
|
||||
PlanetMap ms_planetMap;
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
static void install ()
|
||||
{
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("corellia"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("dantooine"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("dathomir"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("dungeon1"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("endor"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("lok"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("naboo"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("rori"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("talus"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("tatooine"), new WorldSnapshotReaderWriter)));
|
||||
IGNORE_RETURN (ms_planetMap.insert (std::make_pair (std::string ("yavin4"), new WorldSnapshotReaderWriter)));
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
static void remove ()
|
||||
{
|
||||
std::for_each (ms_planetMap.begin (), ms_planetMap.end (), PointerDeleterPairSecond ());
|
||||
ms_planetMap.clear ();
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
void advancePastWhitespace (const char*& buffer)
|
||||
{
|
||||
NOT_NULL (buffer);
|
||||
while (*buffer && (*buffer == ' ' || *buffer == '\t' || *buffer == '\r' || *buffer == '\n'))
|
||||
++buffer;
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
void advancePastToken (const char*& buffer)
|
||||
{
|
||||
NOT_NULL (buffer);
|
||||
while (*buffer && !(*buffer == ' ' || *buffer == '\t' || *buffer == '\r' || *buffer == '\n'))
|
||||
++buffer;
|
||||
|
||||
advancePastWhitespace (buffer);
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
|
||||
void WorldSnapshotParser::createWorldSnapshots (const char* const filename)
|
||||
{
|
||||
//-- make sure the file exists
|
||||
FILE* infile = fopen (filename, "rt");
|
||||
FATAL (!infile, ("%s does not exist", filename));
|
||||
|
||||
//-- install
|
||||
install ();
|
||||
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("----- START: WorldSnapshotParser::createWorldSnapshots -----\n"));
|
||||
|
||||
//-- setup parsing
|
||||
char buffer [1024];
|
||||
char planetName [32];
|
||||
int networkIdInt;
|
||||
Vector position;
|
||||
Quaternion orientation;
|
||||
int containedByNetworkIdInt;
|
||||
char serverObjectTemplateName [256];
|
||||
int cellIndex;
|
||||
uint32 portalLayoutCrc;
|
||||
std::vector<const ObjectTemplate*> objectTemplateList;
|
||||
std::vector<int> validNetworkIdList;
|
||||
|
||||
/*
|
||||
select scene_id||chr(9)||
|
||||
object_id||chr(9)||
|
||||
x||chr(9)||
|
||||
y||chr(9)||
|
||||
z||chr(9)||
|
||||
quaternion_w||chr(9)||
|
||||
quaternion_x||chr(9)||
|
||||
quaternion_y||chr(9)||
|
||||
quaternion_z||chr(9)||
|
||||
contained_by||chr(9)||
|
||||
object_template_crc||chr(10)
|
||||
cell_index where object_template == ms_serverCellObjectTemplateName
|
||||
<portalProperty.crc>
|
||||
*/
|
||||
|
||||
//-- scan each line of the file
|
||||
bool quit = false;
|
||||
while (!quit && fgets (buffer, 1024, infile) != 0)
|
||||
{
|
||||
const char* current = buffer;
|
||||
|
||||
//-- skip past blank lines
|
||||
advancePastWhitespace (current);
|
||||
if (*current == 0)
|
||||
continue;
|
||||
|
||||
//-- start parsing parameters
|
||||
sscanf (current, "%s", planetName);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%i", &networkIdInt);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%f", &position.x);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%f", &position.y);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%f", &position.z);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%f", &orientation.w);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%f", &orientation.x);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%f", &orientation.y);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%f", &orientation.z);
|
||||
advancePastToken (current);
|
||||
|
||||
sscanf (current, "%i", &containedByNetworkIdInt);
|
||||
advancePastToken (current);
|
||||
|
||||
char possibleServerObjectTemplateName [256];
|
||||
sscanf (current, "%s", possibleServerObjectTemplateName);
|
||||
advancePastToken (current);
|
||||
|
||||
if (possibleServerObjectTemplateName [0] == 'o')
|
||||
strcpy (serverObjectTemplateName, possibleServerObjectTemplateName);
|
||||
else
|
||||
strcpy (serverObjectTemplateName, ObjectTemplateList::lookUp (static_cast<uint32> (atoi (possibleServerObjectTemplateName))).getString ());
|
||||
|
||||
//-- check to see of the object is a cell, and if so, read a cell index (all cells have a cell index)
|
||||
cellIndex = 0;
|
||||
if (strcmp (serverObjectTemplateName, ms_serverCellObjectTemplateName) == 0)
|
||||
{
|
||||
sscanf (current, "%i", &cellIndex);
|
||||
advancePastToken (current);
|
||||
}
|
||||
|
||||
//-- check to see if the object is at the origin
|
||||
if (containedByNetworkIdInt == 0 && position == Vector::zero)
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - object %s is at the origin of the world on planet %s\n", networkIdInt, serverObjectTemplateName, planetName));
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- check to see if the object is too close to the origin
|
||||
if (containedByNetworkIdInt == 0 && position.magnitude () < 10.f)
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - object %s is suspiciously close to the origin of the world on planet %s\n", networkIdInt, serverObjectTemplateName, planetName));
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- check to see of the line has a portal crc (may be there, may not)
|
||||
portalLayoutCrc = 0;
|
||||
sscanf (current, "%lu", &portalLayoutCrc);
|
||||
|
||||
//-- find the planet
|
||||
const std::string planetNameString (planetName);
|
||||
PlanetMap::iterator iter = ms_planetMap.find (planetNameString);
|
||||
if (iter != ms_planetMap.end ())
|
||||
{
|
||||
WorldSnapshotReaderWriter* const worldSnapshotWriter = iter->second;
|
||||
NOT_NULL (worldSnapshotWriter);
|
||||
|
||||
//-- verify that the object has a valid contained by object
|
||||
if (containedByNetworkIdInt != 0)
|
||||
{
|
||||
std::sort (validNetworkIdList.begin (), validNetworkIdList.end ());
|
||||
if (!std::binary_search (validNetworkIdList.begin (), validNetworkIdList.end (), containedByNetworkIdInt))
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - containedByNetworkId %i not found for %s\n", networkIdInt, containedByNetworkIdInt, serverObjectTemplateName));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//-- check to see that the server object template exists
|
||||
if (!TreeFile::exists (serverObjectTemplateName))
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s does not exist\n", networkIdInt, serverObjectTemplateName));
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- check to see that the object template is of the correct type
|
||||
const ServerObjectTemplate* const serverObjectTemplate = dynamic_cast<const ServerObjectTemplate*> (ObjectTemplateList::fetch (serverObjectTemplateName));
|
||||
if (!serverObjectTemplate)
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - object template %s is not a valid ServerObjectTemplate\n", networkIdInt, serverObjectTemplateName));
|
||||
continue;
|
||||
}
|
||||
|
||||
objectTemplateList.push_back (serverObjectTemplate);
|
||||
|
||||
if (!(serverObjectTemplate->getId () == ServerBuildingObjectTemplate::ServerBuildingObjectTemplate_tag ||
|
||||
serverObjectTemplate->getId () == ServerCellObjectTemplate::ServerCellObjectTemplate_tag ||
|
||||
serverObjectTemplate->getId () == ServerTangibleObjectTemplate::ServerTangibleObjectTemplate_tag ||
|
||||
serverObjectTemplate->getId () == ServerStaticObjectTemplate::ServerStaticObjectTemplate_tag))
|
||||
{
|
||||
char tagString [5];
|
||||
ConvertTagToString (serverObjectTemplate->getId (), tagString);
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - object template %s not building, cell, or static [%s]\n", networkIdInt, serverObjectTemplateName, tagString));
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- compute the transform
|
||||
Transform transform_p;
|
||||
orientation.getTransform (&transform_p);
|
||||
transform_p.setPosition_p (position);
|
||||
|
||||
//-- extract any necessary variables from the object template
|
||||
const std::string& sharedObjectTemplateName = serverObjectTemplate->getSharedTemplate ();
|
||||
|
||||
//-- check to see that the shared object template exists
|
||||
if (!TreeFile::exists (sharedObjectTemplateName.c_str ()))
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s specifies shared object template %s which does not exist\n", networkIdInt, serverObjectTemplateName, sharedObjectTemplateName.c_str ()));
|
||||
continue;
|
||||
}
|
||||
|
||||
const float radius = serverObjectTemplate->getUpdateRanges (ServerObjectTemplate::UR_far);
|
||||
|
||||
//-- verify portalLayoutCrc
|
||||
{
|
||||
//-- make sure the shared template could be loaded
|
||||
const SharedObjectTemplate* const sharedObjectTemplate = safe_cast<const SharedObjectTemplate*> (ObjectTemplateList::fetch (sharedObjectTemplateName.c_str ()));
|
||||
if (!sharedObjectTemplate)
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s specifies shared object template %s which could not be loaded\n", networkIdInt, serverObjectTemplateName, sharedObjectTemplateName.c_str ()));
|
||||
continue;
|
||||
}
|
||||
|
||||
objectTemplateList.push_back (sharedObjectTemplate);
|
||||
|
||||
//--
|
||||
const std::string& portalLayoutFilename = sharedObjectTemplate->getPortalLayoutFilename ();
|
||||
if (!portalLayoutFilename.empty ())
|
||||
{
|
||||
uint32 extractedPortalLayoutCrc;
|
||||
if (!PortalPropertyTemplate::extractPortalLayoutCrc (portalLayoutFilename.c_str (), extractedPortalLayoutCrc))
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s specifies shared object template %s with portal layout file %s which could not extract portal layout crc\n", networkIdInt, serverObjectTemplateName, sharedObjectTemplateName.c_str (), portalLayoutFilename.c_str ()));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (portalLayoutCrc != extractedPortalLayoutCrc)
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - server object template %s specifies shared object template %s with portal layout file %s with mismatched crcs [%lu != %lu] <%s %1.2f, %1.2f>\n", networkIdInt, serverObjectTemplateName, sharedObjectTemplateName.c_str (), portalLayoutFilename.c_str (), portalLayoutCrc, extractedPortalLayoutCrc, planetName, position.x, position.z));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-- add the object to the list of valid objects
|
||||
validNetworkIdList.push_back (networkIdInt);
|
||||
|
||||
//-- add to writer
|
||||
worldSnapshotWriter->addObject (
|
||||
networkIdInt,
|
||||
containedByNetworkIdInt,
|
||||
ConstCharCrcString(sharedObjectTemplateName.c_str()),
|
||||
cellIndex,
|
||||
transform_p,
|
||||
radius,
|
||||
portalLayoutCrc);
|
||||
|
||||
// DEBUG_REPORT_LOG_PRINT (true, ("added %s - %s, %s\n", networkIdString, planetName, sharedObjectTemplateName.c_str ()));
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("skipping %i - unknown planet %s\n", networkIdInt, planetName));
|
||||
}
|
||||
}
|
||||
|
||||
//-- release all object templates
|
||||
{
|
||||
uint i;
|
||||
for (i = 0; i < objectTemplateList.size (); ++i)
|
||||
objectTemplateList [i]->releaseReference ();
|
||||
|
||||
objectTemplateList.clear ();
|
||||
}
|
||||
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("----- SUMMARY: WorldSnapshotParser::createWorldSnapshots -----\n"));
|
||||
|
||||
//-- write the planet maps
|
||||
{
|
||||
PlanetMap::iterator iter = ms_planetMap.begin ();
|
||||
for (; iter != ms_planetMap.end (); ++iter)
|
||||
{
|
||||
const WorldSnapshotReaderWriter* const writer = iter->second;
|
||||
|
||||
const std::string fileName = iter->first + ".ws";
|
||||
if (!writer->save (fileName.c_str ()))
|
||||
DEBUG_WARNING (true, ("could not save world snapshot file %s", fileName.c_str ()));
|
||||
|
||||
#ifdef _DEBUG
|
||||
const int numberOfNodes = writer->getNumberOfNodes ();
|
||||
const int totalNumberOfNodes = writer->getTotalNumberOfNodes ();
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("%s has %i root objects and %i total objects\n", iter->first.c_str (), numberOfNodes, totalNumberOfNodes));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//-- remove
|
||||
remove ();
|
||||
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("----- END: WorldSnapshotParser::createWorldSnapshots -----\n"));
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//===================================================================
|
||||
//
|
||||
// WorldSnapshotParser.h
|
||||
// asommers
|
||||
//
|
||||
// copyright 2002, sony online entertainment
|
||||
//
|
||||
//===================================================================
|
||||
|
||||
#ifndef INCLUDED_WorldSnapshotParser_H
|
||||
#define INCLUDED_WorldSnapshotParser_H
|
||||
|
||||
//===================================================================
|
||||
|
||||
class WorldSnapshotParser
|
||||
{
|
||||
public:
|
||||
|
||||
static void createWorldSnapshots (const char* const filename);
|
||||
};
|
||||
|
||||
//===================================================================
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "FirstSwgGameServer.h"
|
||||
@@ -0,0 +1,553 @@
|
||||
#include "FirstSwgGameServer.h"
|
||||
#include "serverGame/GameServer.h"
|
||||
|
||||
#include "LocalizationManager.h"
|
||||
#include "serverGame/SetupServerGame.h"
|
||||
#include "serverGame/ServerWorld.h"
|
||||
#include "serverGame/ServerObjectTemplate.h"
|
||||
#include "ServerObjectLint.h"
|
||||
#include "serverPathfinding/SetupServerPathfinding.h"
|
||||
#include "serverScript/SetupScript.h"
|
||||
#include "serverUtility/SetupServerUtility.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/ExitChain.h"
|
||||
#include "sharedFoundation/FormattedString.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedGame/SetupSharedGame.h"
|
||||
#include "sharedGame/SharedObjectTemplate.h"
|
||||
#include "sharedImage/SetupSharedImage.h"
|
||||
#include "sharedLog/LogManager.h"
|
||||
#include "sharedLog/SetupSharedLog.h"
|
||||
#include "sharedMath/SetupSharedMath.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedObject/SetupSharedObject.h"
|
||||
#include "sharedObject/ObjectTemplateList.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedRegex/SetupSharedRegex.h"
|
||||
#include "sharedRemoteDebugServer/SharedRemoteDebugServer.h"
|
||||
#include "sharedTerrain/SetupSharedTerrain.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "sharedUtility/SetupSharedUtility.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "SwgGameServer/SwgGameServer.h"
|
||||
#include "SwgGameServer/WorldSnapshotParser.h"
|
||||
#include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h"
|
||||
#include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <direct.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include "sharedDebug/DataLint.h"
|
||||
#include "sharedDebug/PerformanceTimer.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedObject/Object.h"
|
||||
#include "sharedObject/ObjectTemplate.h"
|
||||
|
||||
void runDataLint(char const *responsePath);
|
||||
void verifyUpdateRanges (const char* filename);
|
||||
#endif // _DEBUG
|
||||
|
||||
//_____________________________________________________________________
|
||||
/*
|
||||
int WINAPI WinMain(
|
||||
HINSTANCE hInstance, // handle to current instance
|
||||
HINSTANCE hPrevInstance, // handle to previous instance
|
||||
LPSTR lpCmdLine, // pointer to command line
|
||||
int nCmdShow // show state of window
|
||||
)
|
||||
*/
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
// UNREF(hPrevInstance);
|
||||
// UNREF(nCmdShow);
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
// command line hack
|
||||
std::string cmdLine;
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
// setupFoundationData.hInstance = hInstance;
|
||||
setupFoundationData.commandLine = cmdLine.c_str();
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupServerUtility::install();
|
||||
|
||||
SetupSharedRegex::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
|
||||
SetupSharedMath::install();
|
||||
|
||||
SetupSharedUtility::Data setupUtilityData;
|
||||
SetupSharedUtility::setupGameData (setupUtilityData);
|
||||
SetupSharedUtility::install (setupUtilityData);
|
||||
|
||||
SetupSharedRandom::install(int(time(NULL)));
|
||||
{
|
||||
SetupSharedObject::Data data;
|
||||
SetupSharedObject::setupDefaultGameData(data);
|
||||
// we want the SlotIdManager initialized, but we don't need the associated hardpoint names on the server.
|
||||
SetupSharedObject::addSlotIdManagerData(data, false);
|
||||
// we want movement table information on this server
|
||||
SetupSharedObject::addMovementTableData(data);
|
||||
// we want CustomizationData support on this server.
|
||||
SetupSharedObject::addCustomizationSupportData(data);
|
||||
// we want POB ejection point override support.
|
||||
SetupSharedObject::addPobEjectionTransformData(data);
|
||||
// objects should not automatically alter their children and contents
|
||||
data.objectsAlterChildrenAndContents = false;
|
||||
SetupSharedObject::install(data);
|
||||
}
|
||||
|
||||
SetupSharedLog::install(FormattedString<92>().sprintf("SwgGameServer:%d", Os::getProcessId()));
|
||||
|
||||
TreeFile::addSearchAbsolute(0);
|
||||
TreeFile::addSearchPath(".",0);
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
SetupSwgServerNetworkMessages::install();
|
||||
SetupSwgSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedImage::Data setupImageData;
|
||||
SetupSharedImage::setupDefaultData (setupImageData);
|
||||
SetupSharedImage::install (setupImageData);
|
||||
|
||||
SetupSharedGame::Data setupSharedGameData;
|
||||
setupSharedGameData.setUseMountValidScaleRangeTable(true);
|
||||
setupSharedGameData.setUseClientCombatManagerSupport(true);
|
||||
SetupSharedGame::install (setupSharedGameData);
|
||||
|
||||
SetupSharedTerrain::Data setupSharedTerrainData;
|
||||
SetupSharedTerrain::setupGameData (setupSharedTerrainData);
|
||||
SetupSharedTerrain::install (setupSharedTerrainData);
|
||||
|
||||
SetupScript::Data setupScriptData;
|
||||
SetupScript::setupDefaultGameData(setupScriptData);
|
||||
SetupScript::install();
|
||||
|
||||
SetupServerPathfinding::install();
|
||||
|
||||
//-- setup game server
|
||||
SetupServerGame::install();
|
||||
|
||||
SharedRemoteDebugServer::install();
|
||||
|
||||
//-- setup game server
|
||||
cmdLine = "";
|
||||
// now, the real command line
|
||||
for(i = 0; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Archive::ByteStream bs;
|
||||
UNREF(bs);
|
||||
|
||||
NetworkHandler::install();
|
||||
SwgGameServer::install();
|
||||
GameServer::getInstance().setCommandLine(cmdLine);
|
||||
|
||||
#ifdef _DEBUG
|
||||
//-- see if the game server is being run in a mode to parse the database dump to create planetary snapshot files
|
||||
const char* const createWorldSnapshots = ConfigFile::getKeyString("WorldSnapshot", "createWorldSnapshots", 0);
|
||||
if (createWorldSnapshots)
|
||||
{
|
||||
WorldSnapshotParser::createWorldSnapshots (createWorldSnapshots);
|
||||
}
|
||||
else
|
||||
//-- see if the gameserver is to be run in a mode to scan update ranges
|
||||
if (ConfigFile::getKeyBool ("SwgGameServer", "verifyUpdateRanges", false))
|
||||
{
|
||||
ServerWorld::install ();
|
||||
verifyUpdateRanges ("../../exe/win32/serverobjecttemplates.txt");
|
||||
ServerWorld::remove ();
|
||||
}
|
||||
else
|
||||
if (!ConfigFile::getKeyBool("SwgGameServer/DataLint", "disable", true))
|
||||
{
|
||||
runDataLint("../../exe/win32/DataLintServer.rsp");
|
||||
}
|
||||
else
|
||||
#endif // _DEBUG
|
||||
{
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(GameServer::run);
|
||||
}
|
||||
|
||||
NetworkHandler::remove();
|
||||
SetupServerGame::remove();
|
||||
|
||||
SharedRemoteDebugServer::remove();
|
||||
SetupSharedLog::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void verifyUpdateRanges (const char* const filename)
|
||||
{
|
||||
FILE* const infile = fopen (filename, "rt");
|
||||
if (!infile)
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: response file %s could not be opened\n", filename));
|
||||
return;
|
||||
}
|
||||
|
||||
char serverObjectTemplateName [1024];
|
||||
while (fscanf (infile, "%s", serverObjectTemplateName) != EOF)
|
||||
{
|
||||
//-- does the name contain test?
|
||||
if (strstr (serverObjectTemplateName, "test") != 0)
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: skipping test object template %s\n", serverObjectTemplateName));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strstr (serverObjectTemplateName, "e3_") != 0)
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: skipping test object template %s\n", serverObjectTemplateName));
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- get the object template
|
||||
const ObjectTemplate* const objectTemplate = ObjectTemplateList::fetch (serverObjectTemplateName);
|
||||
if (!objectTemplate)
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid object template\n", serverObjectTemplateName));
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- make sure its a server object template
|
||||
const ServerObjectTemplate* const serverObjectTemplate = dynamic_cast<const ServerObjectTemplate*> (objectTemplate);
|
||||
if (!serverObjectTemplate)
|
||||
{
|
||||
objectTemplate->releaseReference ();
|
||||
DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid server object template\n", serverObjectTemplateName));
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- make sure it has a shared object template
|
||||
const std::string& sharedObjectTemplateName = serverObjectTemplate->getSharedTemplate ();
|
||||
if (sharedObjectTemplateName.empty ())
|
||||
{
|
||||
objectTemplate->releaseReference ();
|
||||
continue;
|
||||
}
|
||||
|
||||
//-- make sure the shared template exists
|
||||
const SharedObjectTemplate* const sharedObjectTemplate = safe_cast<const SharedObjectTemplate*> (ObjectTemplateList::fetch (sharedObjectTemplateName.c_str ()));
|
||||
if (!sharedObjectTemplate)
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("verifyUpdateRanges: %s is not a valid shared object template for server object template %s\n", sharedObjectTemplateName.c_str (), serverObjectTemplateName));
|
||||
objectTemplate->releaseReference ();
|
||||
continue;
|
||||
}
|
||||
|
||||
const float farUpdateRange = serverObjectTemplate->getUpdateRanges (ServerObjectTemplate::UR_far);
|
||||
DEBUG_REPORT_LOG (true, ("OK:\t%s\t%s\t%1.1f\n", serverObjectTemplateName, sharedObjectTemplateName.c_str (), farUpdateRange));
|
||||
objectTemplate->releaseReference ();
|
||||
}
|
||||
}
|
||||
|
||||
static std::string currentLintedAsset;
|
||||
static int m_startIndex = 0;
|
||||
static int m_numberOfFilesToLint = -1;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static int ExceptionHandler(LPEXCEPTION_POINTERS exceptionPointers)
|
||||
{
|
||||
UNREF(exceptionPointers);
|
||||
|
||||
static bool entered = false;
|
||||
|
||||
// make the routine safe from re-entrance
|
||||
|
||||
if (entered)
|
||||
{
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
entered = true;
|
||||
|
||||
// tell the Os not to abort so we can rethrow the exception
|
||||
|
||||
Os::returnFromAbort();
|
||||
|
||||
// Let the ExitChain do its job
|
||||
|
||||
DataLint::pushAsset(currentLintedAsset.c_str());
|
||||
FATAL(true, ("ExceptionHandler invoked - A crash just occured. The asset is bad or it is constructed improperly with DataLint."));
|
||||
DataLint::popAsset();
|
||||
|
||||
// rethrow the exception so that the debugger can catch it
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH; //lint !e527 // Unreachable
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static void lintType(char const *filePath, DataLint::AssetType const assetType, bool const skip)
|
||||
{
|
||||
DataLint::setCurrentAssetType(assetType);
|
||||
|
||||
static int assetNumber = 0;
|
||||
|
||||
if (!skip)
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("%5i Linting file %s... ", assetNumber, filePath));
|
||||
|
||||
bool failed = false;
|
||||
|
||||
try
|
||||
{
|
||||
switch (assetType)
|
||||
{
|
||||
case DataLint::AT_objectTemplate:
|
||||
{
|
||||
const ObjectTemplate *objectTemplate = ObjectTemplateList::fetch(filePath);
|
||||
if (objectTemplate)
|
||||
{
|
||||
objectTemplate->testValues();
|
||||
|
||||
// if file has the directory "base" in it's path, don't
|
||||
// create an object
|
||||
if (strstr(filePath, "/base/") == NULL)
|
||||
{
|
||||
Object* const object = objectTemplate->createObject ();
|
||||
if (object != NULL)
|
||||
delete object;
|
||||
}
|
||||
|
||||
objectTemplate->releaseReference();
|
||||
}
|
||||
else
|
||||
{
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DataLint::AT_unSupported:
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (failed)
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("failed\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("ok\n"));
|
||||
}
|
||||
}
|
||||
catch (FatalException const &e)
|
||||
{
|
||||
DEBUG_REPORT_LOG (true, ("failed\n"));
|
||||
|
||||
DataLint::logWarning(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
++assetNumber;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static void makeMicrosoftHappyAboutObjectUnWinding(char const *filePath, DataLint::AssetType const assetType, bool const skip)
|
||||
{
|
||||
__try
|
||||
{
|
||||
lintType(filePath, assetType, skip);
|
||||
}
|
||||
__except (ExceptionHandler(GetExceptionInformation()))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static void lint(char const *dataTypeString, DataLint::AssetType const assetType)
|
||||
{
|
||||
DataLint::StringPairList stringPairList(DataLint::getList(assetType));
|
||||
DataLint::StringPairList::const_iterator dataLintStringListIter = stringPairList.begin();
|
||||
|
||||
DEBUG_REPORT_LOG_PRINT(1, ("Linting %d %s assets\n", stringPairList.size(), dataTypeString));
|
||||
|
||||
int currentIndex = 0;
|
||||
for (; dataLintStringListIter != stringPairList.end(); ++dataLintStringListIter)
|
||||
{
|
||||
{
|
||||
if ((currentIndex % 10) == 0)
|
||||
{
|
||||
//-- see if a file exists to abort
|
||||
|
||||
FILE *file = fopen("stoplint.dat", "rt");
|
||||
|
||||
if (file)
|
||||
{
|
||||
fclose(file);
|
||||
DEBUG_REPORT_LOG_PRINT(1, ("Stopping all DataLint processing for %s.\n", dataTypeString));
|
||||
DataLint::logWarning("Forced DataLint stop. Delete \"stoplint.dat\" to DataLint all the assets.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char const *filePath = dataLintStringListIter->first.c_str();
|
||||
currentLintedAsset = dataLintStringListIter->second.c_str();
|
||||
|
||||
//DataLint::pushAsset(filePath);
|
||||
makeMicrosoftHappyAboutObjectUnWinding(filePath, assetType, (currentIndex < m_startIndex));
|
||||
//DataLint::popAsset();
|
||||
|
||||
DataLint::clearAssetStack();
|
||||
++currentIndex;
|
||||
|
||||
if ((m_numberOfFilesToLint != -1) && (currentIndex >= (m_startIndex + m_numberOfFilesToLint)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void runDataLint(char const *responsePath)
|
||||
{
|
||||
ServerObjectLint::install();
|
||||
ServerWorld::install();
|
||||
DataLint::setServerMode();
|
||||
|
||||
PerformanceTimer performanceTimer;
|
||||
performanceTimer.start();
|
||||
|
||||
FILE *fp = fopen(responsePath, "r");
|
||||
|
||||
if (fp)
|
||||
{
|
||||
// Default to start with the first asset
|
||||
|
||||
m_startIndex = ConfigFile::getKeyInt("SwgGameServer/DataLint", "startIndex", 0);
|
||||
|
||||
// Default to lint all assets
|
||||
|
||||
m_numberOfFilesToLint = ConfigFile::getKeyInt("SwgGameServer/DataLint", "numberOfFilesToLint", -1);
|
||||
|
||||
// Verify this is a valid resonse file
|
||||
|
||||
char text[4096];
|
||||
fgets(text, sizeof(text), fp);
|
||||
|
||||
if (strstr(text, "Valid DataLint Rsp") == NULL)
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT(1, ("DataLint: Invalid Rsp file: %s\n", responsePath));
|
||||
|
||||
#ifdef WIN32
|
||||
char text[4096];
|
||||
sprintf(text, "Invalid Rsp file specified: %s. Make sure to run DataLintRspBuilder before running DataLint.", responsePath);
|
||||
MessageBox(NULL, text, "DataLint Error!", MB_OK | MB_ICONERROR);
|
||||
#endif // WIN32
|
||||
}
|
||||
else
|
||||
{
|
||||
DataLint::install();
|
||||
|
||||
typedef std::vector<std::string> StringList;
|
||||
StringList stringList;
|
||||
stringList.reserve(32768);
|
||||
|
||||
DEBUG_REPORT_LOG_PRINT(1, ("Loading assets to lint from: %s\n", responsePath));
|
||||
|
||||
while (fgets(text, sizeof(text), fp))
|
||||
{
|
||||
// Remove the newline character
|
||||
|
||||
char *newLineTest = strchr(text, '\n');
|
||||
|
||||
if (newLineTest)
|
||||
{
|
||||
*newLineTest = '\0';
|
||||
}
|
||||
|
||||
// Add the files to the master file list
|
||||
|
||||
stringList.push_back(text);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
// Add files to data lint
|
||||
|
||||
DEBUG_REPORT_LOG_PRINT(1, ("Adding %d assets to DataLint to be categorized\n", stringList.size()));
|
||||
|
||||
StringList::iterator stringListIter = stringList.begin();
|
||||
|
||||
for (; stringListIter != stringList.end(); ++stringListIter)
|
||||
{
|
||||
DataLint::addFilePath((*stringListIter).c_str());
|
||||
}
|
||||
|
||||
if (ConfigFile::getKeyBool("SwgGameServer/DataLint", "objectTemplate", true))
|
||||
{
|
||||
lint("Objects Template", DataLint::AT_objectTemplate);
|
||||
}
|
||||
|
||||
DataLint::report();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_REPORT_LOG_PRINT(1, ("Bad response path specified: %s", responsePath));
|
||||
|
||||
#ifdef WIN32
|
||||
char text[4096];
|
||||
sprintf(text, "Bad response file specified: %s. Make sure to run DataLintRspBuilder before running DataLint.", responsePath);
|
||||
MessageBox(NULL, text, "DataLint Error!", MB_OK | MB_ICONERROR);
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
// Dump the time required to data lint
|
||||
|
||||
performanceTimer.stop();
|
||||
float const dataLintTime = performanceTimer.getElapsedTime();
|
||||
int const seconds = static_cast<int>(dataLintTime) % 60;
|
||||
int const minutes = (static_cast<int>(dataLintTime) - seconds) / 60;
|
||||
DEBUG_REPORT_LOG_PRINT(1, ("DateLint took: %dm %ds\n", minutes, seconds));
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
//_____________________________________________________________________
|
||||
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(swgSharedNetworkMessages)
|
||||
project(swgServerNetworkMessages)
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
|
||||
|
||||
Reference in New Issue
Block a user