************************************************************

* Merged Source Code from Development Trunk: Revision 4063 *
************************************************************
- Source Code is merged from: https://81.169.133.124/source/ja2/branches/Wanne/JA2%201.13%20MP
- This will be the Source for the Beta 2011 Test

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4064 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2011-01-18 09:11:09 +00:00
parent 44e1646410
commit 91087ca8c0
469 changed files with 118108 additions and 24678 deletions
+1203 -1765
View File
File diff suppressed because it is too large Load Diff
+19 -19
View File
@@ -4,6 +4,7 @@
#include "Soldier Init List.h"
#include "Merc Hiring.h"
#include "event pump.h"
#include "Bullets.h"
extern bool isOwnTeamWipedOut;
@@ -20,34 +21,32 @@ extern bool recieved_transfer_settings;
extern INT16 serverSyncClientsDirectory;
extern int PLAYER_TEAM_TIMER_SEC_PER_TICKS;
//extern char CLIENT_NUM[30];
extern int CLIENT_NUM;
extern int ENEMY_ENABLED;
extern int CREATURE_ENABLED;
extern int MILITIA_ENABLED;
extern int CIV_ENABLED;
extern UINT8 gEnemyEnabled;
extern UINT8 gCreatureEnabled;
extern UINT8 gMilitiaEnabled;
extern UINT8 gCivEnabled;
extern int MAX_CLIENTS;
extern int SAME_MERC;
extern int PLAYER_BSIDE;
extern UINT8 cMaxClients;
extern UINT8 cSameMercAllowed;
extern UINT8 cGameType;
extern bool allowlaptop;
extern UINT8 netbTeam;
extern UINT8 ubID_prefix;
extern FLOAT DAMAGE_MULTIPLIER;
extern FLOAT cDamageMultiplier;
//OJW - 20081218
extern int RANDOM_SPAWN;
extern int RANDOM_MERCS;
extern UINT8 gRandomStartingEdge;
extern UINT8 gRandomMercs;
//OJW - 20090317
extern bool is_game_started;
//OJW - 20090403
extern int OVERRIDE_MAX_AI;
extern UINT8 gMaxEnemiesEnabled;
//OJW - 20090405
extern STRING512 gCurrentTransferFilename;
@@ -58,17 +57,15 @@ extern UINT32 crate_usMapPos;
//extern int INTERRUPTS;
extern int ALLOW_EQUIP;
extern UINT8 cAllowMercEquipment;
extern INT32 MAX_MERCS;
extern UINT8 cMaxMercs;
void lockui (bool unlock);
void start_battle ( void );
void DropOffItemsInSector( UINT8 ubOrderNum );
void test_func2 ( void );
void mp_help (void);
void mp_help2 (void);
void grid_display ( void);
@@ -97,7 +94,7 @@ void send_stance ( SOLDIERTYPE *pSoldier, UINT8 ubDesiredStance );
void send_dir ( SOLDIERTYPE *pSoldier, UINT16 usDesiredDirection );
void send_fire( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo );
void send_hit( EV_S_WEAPONHIT *SWeaponHit );
void send_bullet( BULLET * pBullet, UINT16 usHandItem);
void send_hire( UINT8 iNewIndex, UINT8 ubCurrentSoldier, INT16 iTotalContractLength, BOOLEAN fCopyProfileItemsOver);
void send_dismiss( UINT8 ubCurrentSoldier);
@@ -125,6 +122,8 @@ void send_disarm_explosive(UINT32 sGridNo, UINT32 uiWorldIndex, UINT8 ubID);
void OpenChatMsgBox(void);
INT8 FireBullet( SOLDIERTYPE * pFirer, BULLET * pBullet, BOOLEAN fFake );
void reapplySETTINGS();
BOOLEAN CheckConditionsForBattle( GROUP *pGroup ); // this comes from strategic movement.cpp
@@ -140,10 +139,11 @@ extern int client_edges[5];
extern int client_downloading[4];
extern int client_progress[4];
extern char SERVER_NAME[30];
extern char cServerName[30];
//OJW - 20081224
#define MAX_CONNECT_RETRIES 5
#define ENABLE_COLLISION (is_server && pBullet->pFirer->ubID<120) || (!is_server && is_client && pBullet->pFirer->ubID<20) || (!is_server && !is_client)
extern bool auto_retry;
extern int giNumTries;
+15 -38
View File
@@ -1,9 +1,7 @@
#pragma once
//time for a new header :)
extern int readyteamreg[10];
extern bool NOGEAR;
typedef struct
@@ -23,70 +21,49 @@ typedef struct
typedef struct
{
UINT16 ubID;
INT8 bLife;
INT8 bBleeding;
UINT16 ubID;
INT8 bLife;
INT8 bBleeding;
}heal;
typedef struct
{
UINT16 ubID;
INT8 bteam;
}AIint;
extern BOOLEAN gfUIInterfaceSetBusy;
extern int numreadyteams;//for realtime
extern bool requested;
extern bool getReal;
extern UINT8 gubCheatLevel;
// Client variables
extern UINT8 cWeaponReadyBonus;
extern UINT8 cDisableSpectatorMode;
extern UINT8 cDisableMorale;
BOOLEAN DisplayMercsInventory(UINT8 ubMercID);
void send_door ( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fNoAnimations );
void send_changestate (EV_S_CHANGESTATE * SChangeState);
void send_death( SOLDIERTYPE *pSoldier);
void send_hitstruct(EV_S_STRUCTUREHIT * SStructureHit);
void send_hitwindow(EV_S_WINDOWHIT * SWindowHit);
void send_miss(EV_S_MISS * SMiss);
void cheat_func(void);
//void start_tt(void);
void send_miss(EV_S_MISS * SMiss);
void unlock (void);
void UpdateSoldierToNetwork ( SOLDIERTYPE *pSoldier );
extern BOOLEAN gfUIInterfaceSetBusy;
void TrashAllSoldiers( );
void kick_player (void);
void overide_turn (void);
extern bool DISABLE_MORALE;
void send_fireweapon ( EV_S_FIREWEAPON * SFireWeapon);
void end_interrupt ( BOOLEAN fMarkInterruptOccurred );
void EndInterrupt( BOOLEAN fMarkInterruptOccurred );
void sendRT (void);
extern int numreadyteams;//for realtime
extern bool requested;
extern bool getReal;
extern UINT8 gubCheatLevel;
void startCombat(UINT8 ubStartingTeam);
extern int WEAPON_READIED_BONUS;
void intAI (SOLDIERTYPE *pSoldier );
void teamwiped (void);
BOOLEAN check_status (void);
extern UINT8 NumEnemyInSector( );
extern INT8 NumActiveAndConsciousTeamMembers( UINT8 ubTeam );
void send_heal (SOLDIERTYPE *pSoldier );
extern int DISABLE_SPEC_MODE;
void requestAIint(SOLDIERTYPE *pSoldier );
+78 -61
View File
@@ -3,17 +3,43 @@
#include "random.h"
//this one just for structs, variables and functions used between the client and server scripts...
extern char CLIENT_NAME[30];
extern char SERVER_NAME[30];
extern char cClientName[30];
extern char cServerName[30];
extern bool Sawarded;
//extern char *fileToSend;
extern unsigned int setID;
//extern char *fileToSendCopy;
// ja2_mp.ini: File
#define JA2MP_INI_FILENAME "ja2_mp.ini"
// "ja2_mp.ini: Sections
#define JA2MP_INI_INITIAL_SECTION "JA2 Multiplayer Initial Settings"
#define JA2MP_INI_SERVER_SECTION "JA2 Multiplayer Servers"
// ja2_mp.ini: Properties
#define JA2MP_ALLOW_CUSTOM_NIV "INVENTORY_ATTACHMENTS"
#define JA2MP_CIV_ENABLED "ENABLE_CIVILIANS_IN_COOP"
#define JA2MP_CLIENT_NAME "PLAYER_NAME"
#define JA2MP_DAMAGE_MULTIPLIER "WEAPON_DAMAGE"
#define JA2MP_DIFFICULT_LEVEL "DIFFICULTY_LEVEL"
#define JA2MP_DISABLE_BOBBY_RAYS "BOBBY_RAYS"
#define JA2MP_FILE_TRANSFER_DIRECTORY "GAME_DATA_SYNC_DIRECTORY"
#define JA2MP_GAME_MODE "GAME_TYPE"
#define JA2MP_KIT_BAG "KIT_BAG"
#define JA2MP_MAX_CLIENTS "MAX_PLAYERS"
#define JA2MP_MAX_MERCS "MAX_MERCS"
#define JA2MP_OVERRIDE_MAX_AI "MAX_ENEMIES_IN_COOP"
#define JA2MP_RANDOM_EDGES "STARTING_SECTOR_EDGE"
#define JA2MP_RANDOM_MERCS "HIRE_MERCS_METHOD"
#define JA2MP_REPORT_NAME "REPORT_HIRED_MERC_NAME"
#define JA2MP_SAME_MERC "SAME_MERC_ALLOWED"
#define JA2MP_SERVER_IP "SERVER_IP"
#define JA2MP_SERVER_NAME "SERVER_NAME"
#define JA2MP_SERVER_PORT "SERVER_PORT"
#define JA2MP_STARTING_BALANCE "STARTING_CASH"
#define JA2MP_SYNC_CLIENTS_MP_DIR "SYNC_GAME_DIRECTORY"
#define JA2MP_TIMED_TURN_SECS_PER_TICK "TIMED_TURNS"
#define JA2MP_TIME "STARTING_TIME"
#define JA2MP_NEW_TRAITS "SKILL_TRAITS"
typedef struct
{
@@ -26,60 +52,56 @@ typedef struct
typedef struct
{
int max_clients;
int same_merc;
float damage_multiplier;
INT16 gsMercArriveSectorX;
INT16 gsMercArriveSectorY;
int ENEMY_ENABLED;
int CREATURE_ENABLED;
int MILITIA_ENABLED;
int CIV_ENABLED;
int gsPLAYER_BSIDE;
INT32 secs_per_tick;
INT32 starting_balance;
bool soDis_Bobby;
bool soDis_Equip;
UINT8 maxClients;
UINT8 sameMercAllowed;
float damageMultiplier;
INT16 gsMercArriveSectorX;
INT16 gsMercArriveSectorY;
UINT8 enemyEnabled;
UINT8 creatureEnabled;
UINT8 militiaEnabled;
UINT8 civEnabled;
UINT8 gameType;
INT32 secondsPerTick;
INT32 startingCash;
UINT8 disableBobbyRay;
UINT8 disableMercEquipment;
BOOLEAN sofGunNut;
UINT8 soubGameStyle;
UINT8 soubDifficultyLevel;
UINT8 soubSkillTraits;
BOOLEAN sofTurnTimeLimit;
BOOLEAN sofIronManMode;
UINT8 soubBobbyRay;
BOOLEAN sofNewInv;
INT32 gsMAX_MERCS;
UINT8 client_num;
char client_name[30];
char client_names[4][30];
// OJW - added 20081204
int client_edges[5];
int client_teams[4];
char server_name[30];
//int cl_ops[4];
int team;
int TESTING;
char kitbag[100];
bool emorale;
int gsREPORT_NAME;
int cl_edge;
float TIME;
int WEAPON_READIED_BONUS;
int ALLOW_CUSTOM_NIV;
int DISABLE_SPEC_MODE;
UINT8 soubBobbyRay;
UINT8 maxMercs;
UINT8 client_num;
char client_name[30];
char client_names[4][30];
int client_edges[5];
int client_teams[4];
char server_name[30];
int team;
char kitBag[100];
UINT8 disableMorale;
UINT8 reportHiredMerc;
UINT8 startingSectorEdge;
float startingTime;
UINT8 weaponReadyBonus;
UINT8 inventoryAttachment;
UINT8 disableSpectatorMode;
// OJW - added 20081220
int RANDOM_SPAWN;
int RANDOM_MERCS;
int random_mercs[7];
char server_version[30];
UINT8 randomStartingEdge;
UINT8 randomMercs;
int random_mercs[7];
char server_version[30];
// OJW - added 20091024
UINT32 random_table[MAX_PREGENERATED_NUMS];
UINT32 random_table[MAX_PREGENERATED_NUMS];
} settings_struct;
// WANNE: FILE TRANSFER
typedef struct
{
STRING512 fileTransferDirectory;
//char fileTransferDirectory[600]; // The file transfer directory path from the server
STRING512 fileTransferDirectory;
int syncClientsDirectory; // Does the server want to sync files to the clients
char serverName[30]; // The name of the server. This is used on the client side as a folder inside the client transfer directory
long totalTransferBytes;
@@ -90,7 +112,7 @@ typedef struct
{
INT16 gsMercArriveSectorX;
INT16 gsMercArriveSectorY;
float TIME;
float startingTime;
} mapchange_struct;
typedef struct
@@ -112,18 +134,6 @@ typedef struct
UINT8 downloading;
} progress_struct;
//typedef struct
//{
// int clnum;
// UINT8 ubid;
//}ovh_struct;
//
//typedef struct
//{
// UINT8 ubid;
//}adv;
typedef struct
{
BOOLEAN fMarkInterruptOccurred;
@@ -142,3 +152,10 @@ typedef struct
UINT8 ubStartingTeam;
}sc_struct;
namespace ja2
{
namespace mp
{
void InitializeMultiplayerProfile(vfs::Path const& profileRoot);
}
}
+253 -495
View File
File diff suppressed because it is too large Load Diff
+126
View File
@@ -0,0 +1,126 @@
#include "transfer_rules.h"
#include "Debug.h"
#include <vfs/Core/vfs.h>
#include <vfs/Core/vfs_file_raii.h>
#include <vfs/Core/File/vfs_file.h>
#include <vfs/Tools/vfs_parser_tools.h>
#include <vfs/Tools/vfs_tools.h>
CTransferRules::CTransferRules()
: m_eDefaultAction(ACCEPT)
{};
bool CTransferRules::initFromTxtFile(vfs::Path const& sPath)
{
// try to open via VirtualFileSystem
if(getVFS()->fileExists(sPath))
{
return initFromTxtFile(getVFS()->getReadFile(sPath));
}
else
{
// file doesn't exist or VFS not initialized yet
vfs::IBaseFile* pFile = new vfs::CFile(sPath);
if(pFile)
{
bool success = initFromTxtFile(vfs::tReadableFile::cast(pFile));
delete pFile;
return success;
}
}
return false;
}
bool CTransferRules::initFromTxtFile(vfs::tReadableFile* pFile)
{
if(pFile && pFile->openRead())
{
vfs::COpenReadFile rfile(pFile);
std::string sBuffer;
vfs::UInt32 line_counter = 0;
vfs::CReadLine rl(*pFile);
while(rl.getLine(sBuffer))
{
line_counter++;
// very simple parsing : key = value
if(!sBuffer.empty())
{
// remove leading white spaces
::size_t iStart = sBuffer.find_first_not_of(" \t",0);
char first = sBuffer.at(iStart);
switch(first)
{
case '!':
case ';':
case '#':
// comment -> do nothing
break;
default:
::size_t iEnd = sBuffer.find_first_of(" \t", iStart);
if(iEnd != std::string::npos)
{
SRule rule;
std::string action = sBuffer.substr(iStart, iEnd - iStart);
if( vfs::StrCmp::Equal(action, "deny") )
{
rule.action = CTransferRules::DENY;
}
else if( vfs::StrCmp::Equal(action, "accept") )
{
rule.action = CTransferRules::ACCEPT;
}
else
{
std::wstring trybuffer = L"Invalid UTF-8 character in string";
VFS_IGNOREEXCEPTION( trybuffer = vfs::String(sBuffer).c_wcs(), "" ); /* just make sure we don't break off when string conversion fails */
std::wstringstream wss;
wss << L"Unknown action in file \"" << pFile->getPath().c_wcs()
<< L", line " << line_counter << " : " << vfs::String(sBuffer).c_wcs();
SGP_THROW(wss.str().c_str());
}
try
{
rule.pattern = vfs::Path(vfs::trimString(sBuffer, iEnd, sBuffer.length()));
}
catch(vfs::Exception& ex)
{
std::wstringstream wss;
wss << L"Could not convert string, invalid utf8 encoding in file \"" << pFile->getPath().c_wcs()
<< L"\", line " << line_counter;
SGP_RETHROW(wss.str().c_str(), ex);
}
m_listRules.push_back(rule);
}
break;
}; // end switch
} // end if (empty)
} // end while(!eof)
return true;
}
return false;
}
void CTransferRules::setDefaultAction(CTransferRules::EAction act)
{
m_eDefaultAction = act;
}
CTransferRules::EAction CTransferRules::getDefaultAction()
{
return m_eDefaultAction;
}
CTransferRules::EAction CTransferRules::applyRule(vfs::String const& sStr)
{
tPatternList::iterator sit = m_listRules.begin();
for(; sit != m_listRules.end(); ++sit)
{
if(matchPattern(sit->pattern(), sStr))
{
return sit->action;
}
}
return m_eDefaultAction;
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef _TRANSFER_RULES_H_
#define _TRANSFER_RULES_H_
#include <vfs/Core/vfs_path.h>
#include <vfs/Core/Interface/vfs_file_interface.h>
#include <list>
class CTransferRules
{
public:
enum EAction
{
DENY,
ACCEPT,
};
public:
CTransferRules();
bool initFromTxtFile(vfs::Path const& sPath);
bool initFromTxtFile(vfs::tReadableFile* pFile);
void setDefaultAction(EAction act);
EAction getDefaultAction();
EAction applyRule(vfs::String const& sStr);
private:
struct SRule
{
EAction action;
vfs::Path pattern;
};
typedef std::list<SRule> tPatternList;
tPatternList m_listRules;
EAction m_eDefaultAction;
};
#endif // _TRANSFER_RULES_H_