This engine provides the following functionality
Definition in file AEngine.h.
#include "ExternalLibs.h"
#include "ATypes.h"
#include "AConstants.h"
#include "AUtil.h"
#include <stdlib.h>
#include <crtdbg.h>
Include dependency graph for AEngine.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | DEBUG_CLIENTBLOCK |
| #define | PROFILER_FUNCTION(s) AProfilerBlock funcProfBlock(s); |
Functions | |
| void | sys_init (HINSTANCE hInst, int width, int height, int colorDepth, bool fullScreen) |
| setup the AEngine. You should call this before doing anything else hInst is passed to you by WinMain. Just pass it along to this function note that not all modes can be supported by your video card try standard things such as 800x600x16bit or 1024x768x32bit | |
| void | sys_setSkipRate (int rate) |
| rate=0 means try never to skip any frame. rate=1 means render every other frame | |
| void | sys_setInitFunc (AierraInitFunc f) |
| set call-back functions so the engine knows how to init, update the game state, render it, and shut down | |
| void | sys_setUpdateFunc (AierraUpdateFunc f) |
| void | sys_setRenderFunc (AierraRenderFunc f) |
| void | sys_setShutdownFunc (AierraShutdownFunc f) |
| void | sys_go () |
| let the program runs. This function doesn't return (until sys_terminate()) | |
| void | sys_terminate () |
| terminate the application. This function never returns | |
| void | sys_showFPS (bool show=true) |
| whether to show the frame rate in the top-right corner | |
| void | sys_showConsole (bool show=true) |
| whether or not to display the console window | |
| void | sys_enableConsoleLog (string filename="console.log") |
| this function must be called before sys_go(); this will log all subsequent output to the console to the specified logfile | |
| ostream & | sys_console () |
| this returns you an output stream that you can write stuffs to they will be displayed on the in-game console window if it is set to visible | |
| void | sys_fastForwardUpdate (int times) |
| quickly update the game state 'times' times. this is quivalent to fast forwarding the game by roughly 'times'/62.5 seconds | |
| void | sys_flushConsole () |
| flushes all texts sent to consol eto log file (if any) | |
| DWORD | sys_getMilliSec () |
| get current time in ms | |
| void | sys_setRandSeed (int seed) |
| use these functions instead of the builtin rand, srand so we can log and keep track of what's going on | |
| int | sys_randInt () |
| FLOAT | sys_randFloat () |
| int | sys_localRandInt () |
| FLOAT | sys_localRandFloat () |
| HWND | sys_getWindowHandle () |
| bool | input_isKeyDown (int key) |
| The input system latches the status of all keys at some frequency. Checks whether a specific key is down, pressed or released 'down' means the key was held down at the time we last latch 'pressed' means the key was previously 'up', but just became 'down' 'released' means the key was previously 'down' but just became 'up'. | |
| bool | input_isKeyPressed (int key) |
| bool | input_isKeyReleased (int key) |
| void | input_resetVKeyMapping () |
| this resets all mapping to default values. i.e. the virtual key 'A' is the same as the absolute key 'A' | |
| void | input_mapVKey (int key, int VKey) |
| bool | input_isVKeyDown (int VKey) |
| bool | input_isVKeyPressed (int VKey) |
| bool | input_isVKeyReleased (int VKey) |
| bool | input_isMouseLBDown () |
| check whether the left/middle/right mouse button is down, clicked or double clicked | |
| bool | input_isMouseMBDown () |
| bool | input_isMouseRBDown () |
| bool | input_isMouseLBClicked () |
| bool | input_isMouseMBClicked () |
| bool | input_isMouseRBClicked () |
| bool | input_isMouseLBDblClicked () |
| bool | input_isMouseMBDblClicked () |
| bool | input_isMouseRBDblClicked () |
| float | input_getMouseX () |
| float | input_getMouseY () |
| float | input_getMouseWheel () |
| float | input_mouseIdleTime () |
| AFont | load_font (string fontName, string filename="") |
| AMesh | load_mesh (string filename) |
| ATexture | load_texture (string filename) |
| ATerrain | load_terrain (string filename, FLOAT sizeX, FLOAT sizeY, FLOAT sizeZ, FLOAT offsetZ) |
| void | overlay_point (const Vec2D pt, const FLOAT size=1.0f, const Vec3D rgb=Colors::white, const int blendMode=BlendModes::NONE, const FLOAT alpha=1.0f, const int priority=0) |
| void | overlay_line (const Vec2D pt1, const Vec2D pt2, const Vec3D rgb=Colors::white, const int blendMode=BlendModes::NONE, const FLOAT alpha=1.0f, const int priority=0, const int pattern=0) |
| void | overlay_rect (const Vec2D pt1, const Vec2D pt2, const bool fill=true, const Vec3D rgb=Colors::white, const int blendMode=BlendModes::NONE, const FLOAT alpha=1.0f, const int priority=0) |
| ostream & | overlay_text () |
| void | overlay_textOut (const Vec2D pos, const FLOAT scale=1.0f, const Vec3D rgb=Colors::white, const AFont font=NULL, const int priority=6) |
| void | overlay_clearText () |
| void | overlay_image (const ATexture image, const Vec2D center, const Vec2D size, const int blendMode=BlendModes::NONE, const FLOAT alpha=1.0f, const int priority=0) |
| void | camera_set (const Vec3D pos, const Vec3D target, const FLOAT smoothness=0.0f) |
| ----------------------------------------------------------------------------------- | |
| void | camera_setScreenSize (FLOAT size) |
| set the portion of the screen that will be drawn on should be called in update(), not render() (nothing) 0<size<=1 (fullscreen) | |
| Vec3D | camera_getPos () |
| get the current camera position | |
| Vec3D | camera_getVec () |
| get the current direction vector | |
| void | camera_addVibration (float amount) |
| void | mesh_render (const AMesh mesh, const Vec3D pos, const Vec3D size, const Vec3D dir, const ATexture texture, const ATexture bumpmap=NULL, const Vec3D stripColor=Colors::red) |
| void | terrain_render (ATerrain terrain, ATexture texLow, ATexture texHigh, ATexture texNormal) |
| FLOAT | terrain_getHeight (ATerrain terrain, FLOAT x, FLOAT y) |
| void | flare_begin (ATexture texture, int maxParticles) |
| void | flare_addParticle (const Vec3D &pos1, const Vec3D &pos2, const Vec4D multiplier, FLOAT dist, FLOAT size) |
| void | flare_end () |
| void | sprite_add (ATexture tex, int blendMode, Vec3D pos, Vec4D multiplier, FLOAT size) |
| Vec3D | math_translateScreenToWorldPlane (const Vec2D pt, FLOAT z) |
| Vec2D | math_translateWorldToScreen (const Vec3D pt) |
| Vec3D | math_translateObjectToWorld (const Vec3D objPos, const Vec3D objDir, const Vec3D objPt) |
| converts a point in object space, given the object's xform, to absolute world space i.e. if you want to know what's the world coordinate of the tip of the wing (x+50 off the jet center) dir is a direction vector of three components { theta, phi, roll }. currently only theta is used | |
| FLOAT | math_dist2D (const Vec2D &a, const Vec2D &b) |
| FLOAT | math_dist3D (const Vec3D &a, const Vec3D &b) |
| FLOAT | math_distPlanar3D (const Vec3D &a, const Vec3D &b) |
| FLOAT | math_clipAngle (FLOAT angle) |
| FLOAT | math_getDir (const Vec3D &from, const Vec3D &to) |
| FLOAT | math_deltaDir (const FLOAT currentDir, const FLOAT newDir) |
| void | profiler_begin (string s) |
| void | profiler_end (string s) |
| void | net_runAsServer (string myIP, string myName, int maxNumPlayers) |
| void | net_acceptMorePlayers () |
| void | net_finalizeGame () |
| void | net_runAsFakeServer (string myName, int maxNumPlayers) |
| bool | net_connectToServer (string ip, string myName) |
| string | net_getSelfIP () |
| bool | net_amIServer () |
| vector< string > | net_getAllPlayers () |
| void | net_send (string msg) |
| string | net_getPlayerName () |
| int | net_getPlayerNumber () |
| int | net_getPlayerNumUsingName (string playerName) |
| string | net_getPlayerNameUsingNum (int num) |
| void | net_disconnect () |
| string | net_recv () |
|
|
|
|
|
|
|
|
Definition at line 69 of file ACamera.cpp. References absf. Referenced by BattleGroup::destroyUnit().
00070 {
00071 amount = absf(amount);
00072 if( AS.camera_vibrateSpeed > 0 )
00073 AS.camera_vibrateSpeed += amount;
00074 else
00075 AS.camera_vibrateSpeed -= amount;
00076 }
|
|
|
get the current camera position
Definition at line 51 of file ACamera.cpp. References Vec3D.
00052 {
00053 return AS.camera_pos;
00054 }
|
|
|
get the current direction vector
Definition at line 56 of file ACamera.cpp. References Vec3D. Referenced by BattleGroup::render().
00057 {
00058 Vec3D dir = AS.camera_target - AS.camera_pos;
00059 FLOAT len = D3DXVec3Length(&dir);
00060 return dir * 1.0f/len;
00061 }
|
|
||||||||||||||||
|
-----------------------------------------------------------------------------------
Definition at line 26 of file ACamera.cpp. References Vec3D. Referenced by BattleEntry::input(), Overhead::overhead_render(), and Overhead::processOverheadInput().
00027 {
00028 assert( 0<=smoothness && smoothness<=1 && "camera smoothness must be between 0,1");
00029 AS.camera_pos = smoothness*AS.camera_pos + (1.0f-smoothness)*pos;
00030 AS.camera_target = smoothness*AS.camera_target + (1.0f-smoothness)*target;
00031
00032 // apply vibration
00033 FLOAT accel = - AS.camera_vibratePos * 5.7f;
00034 AS.camera_vibrateSpeed += accel;
00035 AS.camera_vibrateSpeed *= 0.96f;
00036 AS.camera_vibratePos += AS.camera_vibrateSpeed * 0.4f;
00037 AS.camera_pos.z += AS.camera_vibratePos * 0.05f;
00038 AS.camera_target.z += AS.camera_vibratePos * 0.05f;
00039
00040 // prevents looking straight down
00041 if( AS.camera_pos[0]==AS.camera_target[0] && AS.camera_pos[1]==AS.camera_target[1] )
00042 AS.camera_pos[1] += 0.00001f;
00043
00044 const Vec3D upAxis( 0.0f, 0.0f, 1.0f );
00045 D3DXMatrixLookAtLH(&AS.camera_viewMatrix, &AS.camera_pos, &AS.camera_target, &upAxis );
00046 D3DXMatrixPerspectiveFovLH( &AS.camera_projMatrix, D3DXToRadian(60), 1.33333f, 0.1f, 1000.0f );
00047
00048 AS.camera_world2projMatrix = AS.camera_viewMatrix * AS.camera_projMatrix;
00049 }
|
|
|
set the portion of the screen that will be drawn on should be called in update(), not render() (nothing) 0<size<=1 (fullscreen)
Definition at line 63 of file ACamera.cpp.
00064 {
00065 assert( size>0.0f && size<=1.0f );
00066 AS.camera_screenSize = size;
00067 }
|
|
||||||||||||||||||||||||
|
Definition at line 101 of file ALerpParticle.cpp. Referenced by BattleGroup::render().
00103 {
00104 if(AS.flare_renderCount >= AS.flare_reservedCount ) return; // no more than you reserved
00105 int index = AS.flare_renderCount;
00106 AS.flare_pVertex[index].pos1 = pos1;
00107 AS.flare_pVertex[index].pos2 = pos2;
00108 AS.flare_pVertex[index].colorMultiplier = multiplier;
00109 AS.flare_pVertex[index].dist = dist;
00110 AS.flare_pVertex[index].size = size;
00111 AS.flare_renderCount++;
00112 }
|
|
||||||||||||
|
Definition at line 74 of file ALerpParticle.cpp. References MAX_LERP_COUNT. Referenced by BattleEntry::render().
00075 {
00076 assert(maxParticles>=0 && maxParticles<MAX_LERP_COUNT);
00077
00078 // check if there's enough space in current VB
00079 HRESULT res;
00080 if( AS.flare_startRenderingIndex + maxParticles < MAX_LERP_COUNT )
00081 {
00082 res = AS.flare_vb->Lock( AS.flare_startRenderingIndex*sizeof(LerpParticleVertex),
00083 maxParticles*sizeof(LerpParticleVertex),
00084 (BYTE**)&AS.flare_pVertex, D3DLOCK_NOOVERWRITE );
00085 if( FAILED(res)) throw Error("Can't Lock flareVB");
00086 }
00087 else // renew VB
00088 {
00089 AS.flare_startRenderingIndex = 0;
00090 res = AS.flare_vb->Lock( AS.flare_startRenderingIndex*sizeof(LerpParticleVertex),
00091 maxParticles*sizeof(LerpParticleVertex),
00092 (BYTE**)&AS.flare_pVertex, D3DLOCK_DISCARD );
00093 if( FAILED(res)) throw Error("Can't Lock/Renew flareVB");
00094 }
00095
00096 AS.flare_reservedCount= maxParticles;
00097 AS.flare_renderCount = 0;
00098 AS.flare_texture = texture;
00099 }
|
|
|
Definition at line 114 of file ALerpParticle.cpp. Referenced by BattleEntry::render().
00115 {
00116 AS.flare_vb->Unlock();
00117 }
|
|
|
Definition at line 151 of file AInput.cpp. Referenced by BattleEntry::input(), and Overhead::processOverheadInput().
00152 {
00153 return AS.input_mouseWheel;
00154 }
|
|
|
Definition at line 135 of file AInput.cpp. References mouseSpeed. Referenced by Icon::drawHelpString(), BattleEntry::input(), BattleEntry::inputIssueGroupCommand(), BattleEntry::inputIssueJetsCommand(), BattleEntry::inputSelectGroups(), BattleEntry::inputSelectJets(), HUD::isButtonCallRFMUnitTypeClicked(), HUD::isButtonStopClicked(), Overhead::overhead_render(), Overhead::overhead_update(), Overhead::overheadRender(), Overhead::processOverheadInput(), HUD::processOverheadInput(), HUD::render(), BattleEntry::renderInterface(), renderMainMenu(), BattleEntry::renderMiniMap(), renderMultiplayMenu(), updateInput(), updateMainMenu(), and updateMultiplayMenu().
00136 {
00137 FLOAT x = AS.ndxInput.MouseXPos *mouseSpeed / AS.windowWidth;
00138 //x = 0.5f + (x-0.5f)*2.0f;
00139 if( x<0 ) x=0; else if (x>1) x=1;
00140 return x;
00141 }
|
|
|
Definition at line 143 of file AInput.cpp. References mouseSpeed. Referenced by Icon::drawHelpString(), BattleEntry::input(), BattleEntry::inputIssueGroupCommand(), BattleEntry::inputIssueJetsCommand(), BattleEntry::inputSelectGroups(), BattleEntry::inputSelectJets(), HUD::isButtonCallRFMUnitTypeClicked(), HUD::isButtonStopClicked(), Overhead::overhead_render(), Overhead::overhead_update(), Overhead::overheadRender(), Overhead::processOverheadInput(), HUD::processOverheadInput(), HUD::render(), BattleEntry::renderInterface(), renderMainMenu(), BattleEntry::renderMiniMap(), renderMultiplayMenu(), updateInput(), updateMainMenu(), and updateMultiplayMenu().
00144 {
00145 FLOAT y = AS.ndxInput.MouseYPos *mouseSpeed / AS.windowHeight;
00146 //y = 0.5f + (y-0.5f)*2.0f;
00147 if( y<0 ) y=0; else if (y>1) y=1;
00148 return y;
00149 }
|
|
|
The input system latches the status of all keys at some frequency. Checks whether a specific key is down, pressed or released 'down' means the key was held down at the time we last latch 'pressed' means the key was previously 'up', but just became 'down' 'released' means the key was previously 'down' but just became 'up'.
Definition at line 45 of file AInput.cpp. Referenced by checkSysKeys(), Overhead::doVictoryTest(), BattleEntry::input(), Typer::input(), input_isVKeyDown(), BattleEntry::inputCtrlGroup(), BattleEntry::inputIssueGroupCommand(), HUD::processMiniMapInput(), HUD::processOverheadInput(), and Overhead::processOverheadInput().
00046 {
00047 return AS.keyDownThisCycle[key];
00048 }
|
|
|
Definition at line 50 of file AInput.cpp. Referenced by checkSysKeys(), BattleEntry::input(), Typer::input(), input_isVKeyPressed(), BattleEntry::inputCtrlGroup(), BattleEntry::inputIssueGroupCommand(), BattleEntry::inputIssueJetsCommand(), BattleEntry::inputSelectByHotKey(), Overhead::overhead_update(), HUD::processOverheadInput(), Overhead::processOverheadInput(), updateCredit(), updateMultiplayMenu(), and updateSponsor().
00051 {
00052 return !AS.keyDownLastCycle[key] && AS.keyDownThisCycle[key];
00053 }
|
|
|
Definition at line 55 of file AInput.cpp. Referenced by input_isVKeyReleased().
00056 {
00057 return AS.keyDownLastCycle[key] && !AS.keyDownThisCycle[key];
00058 }
|
|
|
Definition at line 105 of file AInput.cpp. Referenced by BattleEntry::input(), BattleEntry::inputSelectGroups(), BattleEntry::inputSelectJets(), HUD::isButtonCallRFMUnitTypeClicked(), HUD::isButtonStopClicked(), Overhead::overhead_update(), HUD::processMiniMapInput(), Overhead::processOverheadInput(), HUD::processOverheadInput(), updateMainMenu(), and updateMultiplayMenu().
00106 {
00107 return AS.ndxInput.MouseLBClick;
00108 }
|
|
|
Definition at line 120 of file AInput.cpp. Referenced by Overhead::processOverheadInput().
00121 {
00122 return AS.ndxInput.MouseLBDblClick;
00123 }
|
|
|
check whether the left/middle/right mouse button is down, clicked or double clicked
Definition at line 90 of file AInput.cpp. Referenced by Overhead::processOverheadInput().
00091 {
00092 return AS.ndxInput.MouseLB;
00093 }
|
|
|
Definition at line 110 of file AInput.cpp.
00111 {
00112 return AS.ndxInput.MouseMBClick;
00113 }
|
|
|
Definition at line 125 of file AInput.cpp.
00126 {
00127 return AS.ndxInput.MouseMBDblClick;
00128 }
|
|
|
Definition at line 95 of file AInput.cpp.
00096 {
00097 return AS.ndxInput.MouseMB;
00098 }
|
|
|
Definition at line 115 of file AInput.cpp. Referenced by BattleEntry::inputIssueGroupCommand(), BattleEntry::inputIssueJetsCommand(), HUD::processMiniMapInput(), and Overhead::processOverheadInput().
00116 {
00117 return AS.ndxInput.MouseRBClick;
00118 }
|
|
|
Definition at line 130 of file AInput.cpp.
00131 {
00132 return AS.ndxInput.MouseRBDblClick;
00133 }
|
|
|
Definition at line 100 of file AInput.cpp.
00101 {
00102 return AS.ndxInput.MouseRB;
00103 }
|
|
|
Definition at line 73 of file AInput.cpp. References input_isKeyDown().
00074 {
00075 return input_isKeyDown( AS.VKmapping[VKey] );
00076 }
|
|
|
Definition at line 78 of file AInput.cpp. References input_isKeyPressed().
00079 {
00080 return input_isKeyPressed( AS.VKmapping[VKey] );
00081 }
|
|
|
Definition at line 83 of file AInput.cpp. References input_isKeyReleased().
00084 {
00085 return input_isKeyReleased( AS.VKmapping[VKey] );
00086 }
|
|
||||||||||||
|
Definition at line 66 of file AInput.cpp.
00067 {
00068 assert( key>=0 && key<MAX_KEY );
00069 assert( VKey>=0 && VKey<MAX_KEY );
00070 AS.VKmapping[VKey] = key;
00071 }
|
|
|
Definition at line 156 of file AInput.cpp.
00157 {
00158 return AS.input_mouseIdleTickCount / 62.5f;
00159 }
|
|
|
this resets all mapping to default values. i.e. the virtual key 'A' is the same as the absolute key 'A'
Definition at line 60 of file AInput.cpp. References MAX_KEY. Referenced by input_init().
00061 {
00062 for( int i=0; i<MAX_KEY; i++ )
00063 AS.VKmapping[i] = i;
00064 }
|
|
||||||||||||
|
Definition at line 27 of file ALoad.cpp. References AFont, and util_loadFont().
00028 {
00029 AS.res_fonts.push_back( util_loadFont(fontName,filename,18) );
00030 return (int)AS.res_fonts.size()-1;
00031 }
|
|
|
Definition at line 33 of file ALoad.cpp. References AMesh, MeshVertex::cindex, MeshEntry::IBstart, MeshVertex::normal, MeshVertex::pos, MeshEntry::size, MeshEntry::TriCount, UINT, MeshVertex::uv, MeshEntry::VBcount, MeshEntry::VBmin, Vec2D, and Vec3D.
00034 {
00035 ifstream f(filename.c_str());
00036 if(!f) throw Error("Can't read mesh file : "+filename );
00037
00038 vector<Vec3D> vec_pos, vec_normal;
00039 vector<Vec2D> vec_uv;
00040 string cmd;
00041 FLOAT f1, f2, f3;
00042 FLOAT minX, maxX, minY, maxY, minZ, maxZ;
00043 minX = minY = minZ = 100000.0f;
00044 maxX = maxY = maxZ = -100000.0f;
00045
00046 // read it vertex pos, texture, normal arrays
00047 while(true)
00048 {
00049 f >> cmd;
00050 if( cmd=="#" ) // just a comment line. ignore it
00051 {
00052 getline( f, cmd );
00053 }
00054 else if( cmd=="v" ) // vertex position
00055 {
00056 f >> f1 >> f2 >> f3;
00057 vec_pos.push_back( Vec3D(f1,f2,f3) );
00058 if(f1<minX) minX=f1; else if(f1>maxX) maxX=f1;
00059 if(f2<minY) minY=f2; else if(f2>maxY) maxY=f2;
00060 if(f3<minZ) minZ=f3; else if(f3>maxZ) maxZ=f3;
00061 }
00062 else if( cmd=="vt" ) // texture coordinate
00063 {
00064 f >> f1 >> f2 >> f3;
00065 vec_uv.push_back( Vec2D(f1,1.0f-f2) );
00066 }
00067 else if( cmd=="vn" ) // normal
00068 {
00069 f >> f1 >> f2 >> f3;
00070 vec_normal.push_back( Vec3D(f1,f2,f3) );
00071 }
00072 else if( cmd=="g" ) // end of vertex info list
00073 {
00074 getline( f, cmd );
00075 break;
00076 }
00077 }
00078
00079 // read in triangle indices, create&map tuples
00080 map< Int3Tuple, int > tuplesMap;
00081 vector<Int3Tuple> vertices;
00082 vector<USHORT> indices;
00083 map<Int3Tuple,int>::iterator iter;
00084 char skip;
00085 int posIndex, uvIndex, normalIndex;
00086
00087 while(true)
00088 {
00089 f >> cmd;
00090 if( cmd!="f" ) break;
00091
00092 // read the 3 corners of a triangle
00093 for( int corner=0; corner<3; corner++ )
00094 {
00095 f >> posIndex >> skip >> uvIndex >> skip >> normalIndex;
00096 Int3Tuple tuple(posIndex-1,uvIndex-1,normalIndex-1); // -1 because .obj is 1-based
00097 iter = tuplesMap.find(tuple);
00098 if( iter==tuplesMap.end() ) // if this vertex is new, add it
00099 {
00100 tuplesMap[tuple] = (int) vertices.size();
00101 indices.push_back( (USHORT)vertices.size() );
00102 vertices.push_back(tuple);
00103 }
00104 else // but if it's already there, use existing vertex number
00105 indices.push_back( iter->second );
00106 }
00107
00108 }
00109
00110 // concat new data to entire Mesh VB&IB
00111 int vertexOffset = (int) AS.mesh_raw_vb.size();
00112 int indexOffset = (int) AS.mesh_raw_ib.size();
00113 MeshVertex v;
00114 for( UINT i=0; i<vertices.size(); i++ ) // add all vertices
00115 {
00116 v.pos = vec_pos[ vertices[i].a ];
00117 v.uv = vec_uv[ vertices[i].b ];
00118 v.normal = vec_normal[ vertices[i].c ];
00119 v.cindex = 0;
00120 AS.mesh_raw_vb.push_back(v);
00121 }
00122 for( UINT i=0; i<indices.size(); i++ ) // add all indices
00123 {
00124 AS.mesh_raw_ib.push_back( indices[i]+vertexOffset );
00125 }
00126
00127 // add MeshEntry
00128 MeshEntry entry;
00129 entry.IBstart = indexOffset;
00130 entry.TriCount = (UINT) indices.size() / 3;
00131 entry.VBcount = (UINT) vertices.size();
00132 entry.VBmin = vertexOffset;
00133 entry.size = Vec3D( maxX-minX, maxY-minY, maxZ-minZ );
00134 AS.res_meshes.push_back( entry );
00135
00136 return (int)AS.res_meshes.size() - 1;
00137 }
|
|
||||||||||||||||||||||||
|
Definition at line 148 of file ALoad.cpp. References ATerrain, and terrain_create(). Referenced by Globals::ArtWork::ArtWork().
00149 {
00150 return terrain_create(filename,sizeX,sizeY,sizeZ,offsetZ);
00151 }
|
|
|
Definition at line 139 of file ALoad.cpp. References ATexture. Referenced by displayLoadingScreen().
00140 {
00141 LPDIRECT3DTEXTURE8 pTexture;
00142 HRESULT hr = D3DXCreateTextureFromFile( AS.pDevice, filename.c_str(), &pTexture );
00143 if( FAILED(hr) ) throw Error("Cannot Load Texture : "+filename);
00144 AS.res_textures.push_back(pTexture);
00145 return (int)AS.res_textures.size()-1;
00146 }
|
|
|
Definition at line 107 of file AMath.cpp. Referenced by math_getDir(), and Jet::move().
00108 {
00109 if( degree < 0.0f ) return degree + 360.0f;
00110 if( degree >= 360.0f ) return degree - 360.0f;
00111 return degree;
00112 }
|
|
||||||||||||
|
Definition at line 120 of file AMath.cpp. Referenced by BattleGroup::fire(), BattleJets::fireAntiAirMissiles(), and BattleJets::fireAntiSurfaceMissiles().
00121 {
00122 FLOAT delta;
00123 if(newDir>currentDir)
00124 {
00125 delta = newDir - currentDir;
00126 if(delta>180.0f) delta = delta - 360.0f;
00127 }
00128 else
00129 {
00130 delta = newDir - currentDir;
00131 if(delta<-180.0f) delta = 360.0f - delta;
00132 }
00133 return delta;
00134 }
|
|
||||||||||||
|
Definition at line 89 of file AMath.cpp. References Vec2D. Referenced by MilitaryUnit::around(), City::contains(), MilitaryUnit::contains(), Overhead::overhead_update(), Overhead::processOverheadInput(), and sendReinforcement().
00090 {
00091 Vec2D delta = a-b;
00092 return D3DXVec2Length(&delta);
00093 }
|
|
||||||||||||
|
Definition at line 95 of file AMath.cpp. References Vec3D. Referenced by BattleGroup::acquireGroupTargets(), BattleEntry::contains(), BattleEntry::input(), BattleGroup::moveBattleGroup(), BattleGroup::moveUnits(), and Overhead::overheadRender().
00096 {
00097 Vec3D delta = a-b;
00098 return D3DXVec3Length(&delta);
00099 }
|
|
||||||||||||
|
Definition at line 101 of file AMath.cpp. References Vec3D. Referenced by BattleGroup::acquireGroupTargets(), MilitaryUnit::fightingCollision(), BattleGroup::fire(), BattleGroup::fireAntiAir(), BattleJets::fireAntiAirMissiles(), BattleJets::fireAntiSurfaceMissiles(), Overhead::getSurroundingUnits(), Jet::goal(), BattleEntry::input(), MilitaryUnit::nearEachOther(), BattleEntry::renderInterface(), BattleJets::takeHit(), and BattleJets::update().
00102 {
00103 Vec3D delta = a-b;
00104 return sqrtf( delta.x*delta.x + delta.y*delta.y );
00105 }
|
|
||||||||||||
|
Definition at line 114 of file AMath.cpp. References math_clipAngle(), and Vec3D. Referenced by BattleGroup::fire(), BattleJets::fireAntiAirMissiles(), BattleJets::fireAntiSurfaceMissiles(), and Jet::goal().
00115 {
00116 Vec3D targetVec = to - from;
00117 return math_clipAngle( 90-D3DXToDegree( atan2f( targetVec.x, targetVec.y ) ) );
00118 }
|
|
||||||||||||||||
|
converts a point in object space, given the object's xform, to absolute world space i.e. if you want to know what's the world coordinate of the tip of the wing (x+50 off the jet center) dir is a direction vector of three components { theta, phi, roll }. currently only theta is used
Definition at line 77 of file AMath.cpp. Referenced by BattleGroup::BattleGroup(), BattleGroup::drawOutlineBox(), BattleGroup::isContain2DPoint(), BattleGroup::moveUnits(), and BattleJets::render().
00078 {
00079 Matx matTrans, matTheta, matFinal;
00080 Vec3D result;
00081
00082 D3DXMatrixTranslation( &matTrans, objPos[0], objPos[1], objPos[2] );
00083 D3DXMatrixRotationZ( &matTheta, D3DXToRadian(objDir[0]) );
00084 matFinal = matTheta * matTrans;
00085 D3DXVec3TransformCoord( &result, &objPt, &matFinal );
00086 return result;
00087 }
|
|
||||||||||||
|
Definition at line 31 of file AMath.cpp. References Vec3D. Referenced by BattleEntry::inputIssueGroupCommand(), BattleEntry::inputIssueJetsCommand(), Overhead::overheadRender(), Overhead::processOverheadInput(), and BattleEntry::renderInterface().
00032 {
00033 // Get screen space vector
00034 Vec3D v;
00035 v.x = ( 2.0f*pt[0] - 1 ) / AS.camera_projMatrix._11;
00036 v.y = -( 2.0f*pt[1] - 1 ) / AS.camera_projMatrix._22;
00037 v.z = 1.0f;
00038
00039 // Get the inverse view matrix
00040 D3DXMATRIX inv;
00041 D3DXMatrixInverse( &inv, NULL, &AS.camera_viewMatrix );
00042
00043 // Transform to world space vector
00044 Vec3D pt1, pt2, dir;
00045 dir.x = v.x*inv._11 + v.y*inv._21 + v.z*inv._31;
00046 dir.y = v.x*inv._12 + v.y*inv._22 + v.z*inv._32;
00047 dir.z = v.x*inv._13 + v.y*inv._23 + v.z*inv._33;
00048 pt1.x = inv._41;
00049 pt1.y = inv._42;
00050 pt1.z = inv._43;
00051 pt2 = pt1 + 10000.0f * dir;
00052
00053 // construct a plane with specified height
00054 D3DXPLANE plane;
00055 Vec3D planePt(0,0,z), planeNormal(0,0,1);
00056 D3DXPlaneFromPointNormal( &plane, &planePt, &planeNormal );
00057
00058 // find where the vector intersect with the plane
00059 Vec3D intersectPt;
00060 D3DXPlaneIntersectLine( &intersectPt, &plane, &pt1, &pt2 );
00061
00062 return intersectPt;
00063 }
|
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 69 of file AMesh.cpp. Referenced by City::draw(), LightTank::draw(), HeavyTank::draw(), RocketLauncher::draw(), Artillery::draw(), Jet::draw(), MilitaryUnit::drawBox(), City::drawSelectBox(), Overhead::overheadRender(), BattleGroup::render(), BattleJets::render(), BattleEntry::renderBullets(), BattleEntry::renderDebris(), and BattleEntry::renderEnvironment().
00071 {
00072 AS.mesh_renderList.push_back( MeshRenderRequestEntry(mesh,pos,size,dir,
00073 texture,bumpmap,stripColor) );
00074 }
|
|
|
Definition at line 104 of file ANetwork.cpp. Referenced by updateMultiplayMenu().
00105 {
00106 if(AS.net_isFakeServer) return;
00107 if(AS.net_gameFinalized) throw Error("Game already finalized. Can't accept more players");
00108 AS.net_ndxConnect.ScanForPlayers();
00109 }
|
|
|
Definition at line 136 of file ANetwork.cpp. Referenced by BattleEntry::inputIssueGroupCommand(), BattleEntry::inputIssueJetsCommand(), Overhead::overhead_update(), NetworkSubsystem::processNetworkData(), and updateMultiplayMenu().
00137 {
00138 return AS.net_isServer;
00139 }
|
|
||||||||||||
|
Definition at line 65 of file ANetwork.cpp. References sys_console(). Referenced by updateMultiplayMenu().
00066 {
00067 NDX_Connect &net = AS.net_ndxConnect;
00068 if(!net.Create(&netGuid))
00069 {
00070 sys_console() << "Can't create DirectPlay" << endl;
00071 return false;
00072 }
00073
00074 net.SetGuarenteed(true);
00075 if(!net.ConnectTCPIP( (char*)ip.c_str() ))
00076 {
00077 sys_console() << "Can't connect to Server : " << ip << endl;
00078 return false;
00079 }
00080
00081 net.ScanForGames(20,false); // spend 20 millisec searching for a game
00082 if(net.NumGames>0)
00083 {
00084 if(!net.JoinGame(0, (char*)myName.c_str()))
00085 {
00086 sys_console() << "Can't Join Game" << endl;
00087 return false;
00088 }
00089 }
00090 else
00091 {
00092 sys_console() << "No Game Found on that server" << endl;
00093 return false;
00094 }
00095
00096 AS.net_isServer = false;
00097 AS.net_myName = myName;
00098 AS.net_serverSendQueue.resize(0);
00099 AS.net_myPlayerNum = -1;
00100 AS.net_isInit = true;
00101 return true;
00102 }
|
|
|
Definition at line 184 of file ANetwork.cpp.
00185 {
00187 AS.net_ndxConnect.CloseGame();
00188 AS.net_ndxConnect.CloseConnection();
00189 }
|
|
|
Definition at line 118 of file ANetwork.cpp. References net_broadcast(), and net_send(). Referenced by updateMultiplayMenu().
00119 {
00120 NDX_Connect &net = AS.net_ndxConnect;
00121 for( int i=0; i<net.NumPlayers; i++ )
00122 {
00123 ostringstream strm;
00124 strm << "Assign <begin_name>" << net.Players[i].Name << "<end_name> " << i;
00125 net_send( strm.str() );
00126
00127 if( AS.net_myName == net.Players[i].Name ) AS.net_myPlayerNum = i; // server's own number
00128 }
00129
00130 // broadcast server DPID
00131 ostringstream strm;
00132 strm << "ServerDPID " << AS.net_ndxConnect.LocalDPID;
00133 net_broadcast( strm.str() );
00134 }
|
|
|
Definition at line 141 of file ANetwork.cpp. Referenced by NetworkData::hasDataForGameTickArrived(), Overhead::overhead_init(), Overhead::playerExists(), Overhead::printPlayerList(), Overhead::processCommand(), and renderMultiplayMenu().
00142 {
00143 vector<string> result;
00144
00145 if(AS.net_isFakeServer)
00146 {
00147 result.push_back(AS.net_myName);
00148 return result;
00149 }
00150
00151 NDX_Connect &net = AS.net_ndxConnect;
00152 if(!AS.net_gameFinalized) net.ScanForPlayers();
00153
00154 for( int i=0; i<net.NumPlayers; i++ )
00155 result.push_back( net.Players[i].Name );
00156
00157 return result;
00158 }
|
|
|
Definition at line 174 of file ANetwork.cpp. Referenced by Overhead::overhead_update(), and NetworkSubsystem::processNetworkData().
00175 {
00176 return AS.net_myName;
00177 }
|
|
|
Definition at line 288 of file ANetwork.cpp. Referenced by Helper::playerColorToPlayerName(), and Overhead::printPlayerList().
00289 {
00290 map<int,string>::iterator iter = AS.net_mapNumToName.find(num);
00291 if( iter==AS.net_mapNumToName.end() ) return "NoNamePlayer";
00292 return (iter)->second;
00293 }
|
|
|
Definition at line 179 of file ANetwork.cpp. Referenced by Overhead::overhead_init().
00180 {
00181 return AS.net_myPlayerNum;
00182 }
|
|
|
Definition at line 281 of file ANetwork.cpp. Referenced by Overhead::overhead_init(), and Overhead::printPlayerList().
00282 {
00283 map<string,int>::iterator iter = AS.net_mapNameToNum.find(playerName);
00284 if( iter==AS.net_mapNameToNum.end() ) return 0;
00285 return (iter)->second;
00286 }
|
|
|
Definition at line 295 of file ANetwork.cpp. Referenced by updateMultiplayMenu().
00296 {
00297 static bool init = false;
00298 if(!init)
00299 {
00300 init = true;
00301 WSAData wsa;
00302 WSAStartup( MAKEWORD(1,1), &wsa );
00303 }
00304
00305 char hostName[500];
00306 int rc = gethostname(&hostName[0],499);
00307 if(rc!=0) rc = WSAGetLastError();
00308 assert(rc != WSAEFAULT);
00309 assert(rc != WSANOTINITIALISED );
00310 assert(rc != WSAENETDOWN );
00311 assert(rc != WSAEINPROGRESS );
00312
00313 struct hostent *phost = gethostbyname(hostName);
00314 char oip[50];
00315 for (int i = 0; phost->h_addr_list[i] != 0; ++i)
00316 {
00317 struct in_addr addr;
00318 memcpy(&addr, phost->h_addr_list[i], sizeof(struct in_addr));
00319 strcpy(oip,inet_ntoa(addr));
00320 break;
00321 }
00322
00323 return string(oip);
00324 }
|
|
|
Definition at line 191 of file ANetwork.cpp. References net_broadcast(), net_recv(), and sys_console(). Referenced by net_recv(), processIncomingMessages(), and NetworkSubsystem::receiveNetworkData().
00192 {
00193 if(!AS.net_isInit) return "";
00194 NDX_Connect &net = AS.net_ndxConnect;
00195
00196 if(AS.net_isServer) // server, check send queue first
00197 {
00198 if( AS.net_serverSendQueue.size()>0 )
00199 {
00200 string s = *AS.net_serverSendQueue.begin();
00201 AS.net_serverSendQueue.pop_front();
00202 net_broadcast(s);
00203 if( s.find("Assign <begin_name>")==0 ) // player number assignment
00204 {
00205
00206 sys_console() << s << endl;
00207
00208 s = s.substr(19); // skip header
00209 int i = (int)s.find("<end_name>"); // delete footer
00210 string name = s.substr(0,i);
00211
00212
00213 string numStr = s.substr(i+10); // skip footer
00214 istringstream numStrm(numStr.c_str());
00215 int num;
00216 numStrm >> num;
00217
00218 if( name==AS.net_myName ) AS.net_myPlayerNum = num; // it's me! Store my number
00219 AS.net_mapNameToNum[name] = num;
00220 AS.net_mapNumToName[num] = name;
00221
00222 return net_recv(); // grab another msg
00223 }
00224 return s;
00225 }
00226 else if(!AS.net_isFakeServer) // if nothing in queue, do actual recv
00227 {
00228 if(!net.Receive()) return "";
00229 if(net.FromDPID==DPID_SYSMSG) return net_recv(); // it's a system msg, try again
00230 string s((char*)net.RBuffer);
00231 net_broadcast(s);
00232 return s;
00233
00234 }
00235 }
00236 else // clients, just send it to server
00237 {
00238 if(!net.Receive()) return "";
00239 if(net.FromDPID==DPID_SYSMSG) return net_recv(); // it's a system msg, try again
00240 string s((char*)net.RBuffer);
00241 if( s.find("Assign <begin_name>")==0 ) // player number assignment
00242 {
00243
00244 sys_console() << s << endl;
00245
00246 s = s.substr(19); // skip header
00247 int i = (int)s.find("<end_name>"); // delete footer
00248 string name = s.substr(0,i);
00249
00250
00251 string numStr = s.substr(i+10); // skip footer
00252 istringstream numStrm(numStr.c_str());
00253 int num;
00254 numStrm >> num;
00255
00256 if( name==AS.net_myName )
00257 {
00258 AS.net_myPlayerNum = num; // it's me! Store my number
00259 sys_console() << "My num is " << num << endl;
00260 }
00261 AS.net_mapNameToNum[name] = num;
00262 AS.net_mapNumToName[num] = name;
00263 sys_console() << "mapping " << name << " to " << num << endl;
00264
00265 return net_recv(); // grab another msg
00266 }
00267 else if (s.find("ServerDPID")==0 )
00268 {
00269 string tmp;
00270 istringstream strm(s);
00271 strm >> tmp >> AS.net_serverDPID;
00272 return net_recv();
00273 }
00274
00275 return s;
00276 }
00277
00278 return "";
00279 }
|
|
||||||||||||
|
works like net_runAsServer, except no networking actually happens this is useful when you want to test the game solo Definition at line 54 of file ANetwork.cpp. Referenced by updateMainMenu().
00055 {
00056 AS.net_isServer = true;
00057 AS.net_myName = myName;
00058 AS.net_serverSendQueue.resize(0);
00059 AS.net_gameFinalized = false;
00060 AS.net_myPlayerNum = -1;
00061 AS.net_isInit = true;
00062 AS.net_isFakeServer = true;
00063 }
|
|
||||||||||||||||
|
Definition at line 35 of file ANetwork.cpp. Referenced by updateMultiplayMenu().
00036 {
00037 NDX_Connect &net = AS.net_ndxConnect;
00038 if(!net.Create(&netGuid)) throw Error("Can't create DirectPlay");
00039
00040 net.SetGuarenteed(true);
00041 if(!net.ConnectTCPIP( (char*)myIP.c_str() )) throw Error("Can't connect to Server : " + myIP );
00042 if(!net.CreateGame("Aierra Engine Game", (char*)myName.c_str(), maxNumPlayers ))
00043 throw Error("Can't Create Game");
00044
00045 AS.net_isServer = true;
00046 AS.net_myName = myName;
00047 AS.net_serverSendQueue.resize(0);
00048 AS.net_gameFinalized = false;
00049 AS.net_myPlayerNum = -1;
00050 AS.net_isInit = true;
00051 AS.net_isFakeServer = false;
00052 }
|
|
|
Definition at line 160 of file ANetwork.cpp. Referenced by Overhead::askForRandomNumbers(), BattleEntry::inputIssueGroupCommand(), BattleEntry::inputIssueJetsCommand(), net_finalizeGame(), Overhead::overhead_update(), Overhead::processCommand(), HUD::processMiniMapInput(), NetworkSubsystem::processNetworkData(), Overhead::processOverheadInput(), NetworkMessages::sendBuildMessage(), sendGameTickEnd(), Overhead::sendMessageToPrintARandomNumberToTheConsole(), sendReinforcement(), and updateMultiplayMenu().
00161 {
00162 if(!AS.net_isInit) return;
00163 msg += "\0";
00164 if(AS.net_isServer) // server, add to send queue
00165 {
00166 AS.net_serverSendQueue.push_back(msg);
00167 }
00168 else // clients, just send it to server
00169 {
00170 AS.net_ndxConnect.Send( AS.net_serverDPID, &msg[0], (DWORD)msg.length()+1 );
00171 }
00172 }
|
|
|
Definition at line 284 of file AOverlay.cpp. Referenced by overlay_textOut().
00285 {
00286 delete AS.overlay_pTextStream;
00287 AS.overlay_pTextStream = new ostringstream();
00288 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 290 of file AOverlay.cpp. Referenced by displayLoadingScreen(), Overhead::overhead_render(), Overhead::overheadRender(), HUD::render(), Icon::render(), BattleJets::renderIcon(), BattleEntry::renderInterface(), renderMainMenu(), HUD::renderMiniMap(), renderMultiplayMenu(), and renderSponsor().
00292 {
00293 AS.overlay_entries.push_back( OverlayEntry(OpType::OP_IMAGE, blendMode, center, size,
00294 Colors::white, alpha, 0.0f, "", image,priority) );
00295 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 253 of file AOverlay.cpp. Referenced by MilitaryUnit::drawColor(), BattleGroup::drawOutlineBox(), City::drawSelectBox(), Overhead::overheadRender(), BattleGroup::render(), BattleEntry::renderInterface(), and BattleEntry::renderMiniMap().
00255 {
00256 FLOAT floatPattern = *(FLOAT*)(&pattern);
00257 AS.overlay_entries.push_back( OverlayEntry(OpType::OP_LINE, blendMode,
00258 pt1, pt2, rgb, alpha, floatPattern, "", NULL,priority) );
00259 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 246 of file AOverlay.cpp. Referenced by Overhead::overheadRender(), BattleGroup::render(), BattleEntry::renderMiniMap(), and HUD::renderMiniMap().
00248 {
00249 AS.overlay_entries.push_back( OverlayEntry(OpType::OP_POINT, blendMode,
00250 pt, pt, rgb, alpha, size, "", NULL,priority) );
00251 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 261 of file AOverlay.cpp. Referenced by drawBox(), drawConsole(), Icon::drawHelpString(), Icon::drawOutline(), Overhead::overhead_render(), Overhead::overheadRender(), Overhead::printPlayerList(), HUD::render(), BattleEntry::renderJets(), BattleEntry::renderMiniMap(), and HUD::renderMiniMap().
00263 {
00264 if(fill)
00265 AS.overlay_entries.push_back( OverlayEntry(OpType::OP_FILLED_RECT,
00266 blendMode, pt1, pt2, rgb, alpha, 1.0f, "", NULL,priority) );
00267 else
00268 AS.overlay_entries.push_back( OverlayEntry(OpType::OP_EMPTY_RECT,
00269 blendMode, pt1, pt2, rgb, alpha, 1.0f, "", NULL,priority) );
00270 }
|
|
|
Definition at line 272 of file AOverlay.cpp. Referenced by drawConsole(), drawFPS(), Icon::drawHelpString(), City::drawSelectBox(), Overhead::overhead_render(), Overhead::overheadRender(), Globals::MessagesReceived::print(), Overhead::printPlayerList(), Helper::printPlayerNameToScreen(), HUD::render(), BattleEntry::render(), BattleJets::renderIcon(), BattleEntry::renderInterface(), BattleEntry::renderMiniMap(), and renderMultiplayMenu().
00273 {
00274 return *(AS.overlay_pTextStream);
00275 }
|
|
||||||||||||||||||||||||
|
Definition at line 277 of file AOverlay.cpp. References overlay_clearText(). Referenced by drawConsole(), drawFPS(), Icon::drawHelpString(), City::drawSelectBox(), Overhead::overhead_render(), Overhead::overheadRender(), Globals::MessagesReceived::print(), Overhead::printPlayerList(), Helper::printPlayerNameToScreen(), BattleEntry::render(), HUD::render(), BattleJets::renderIcon(), BattleEntry::renderInterface(), BattleEntry::renderMiniMap(), and renderMultiplayMenu().
00278 {
00279 AS.overlay_entries.push_back( OverlayEntry(OpType::OP_TEXT, BlendModes::NONE,
00280 pos, pos, rgb, 1.0f, scale, AS.overlay_pTextStream->str(), font,priority) );
00281 overlay_clearText();
00282 }
|
|
|
Definition at line 56 of file AProfiler.cpp.
00057 {
00058 map<string,__int64>::iterator iter;
00059 iter = AS.profiler_startTime.find(s);
00060 if( iter==AS.profiler_startTime.end() ) // if this is the first time we come across this name
00061 {
00062 AS.profiler_startTime[s] = getOSTime();
00063 AS.profiler_totalTime[s] = 0;
00064 AS.profiler_names.push_back(s);
00065 }
00066 else
00067 {
00068 AS.profiler_startTime[s] = getOSTime();
00069 }
00070 }
|
|
|
Definition at line 72 of file AProfiler.cpp.
00073 {
00074 map<string,__int64>::iterator iter;
00075 iter = AS.profiler_totalTime.find(s);
00076 if( iter==AS.profiler_totalTime.end() )
00077 {
00078 throw Error("Profiler_end("+s+") not preceded by Profiler_begin");
00079 }
00080 else
00081 {
00082 iter->second += getOSTime() - AS.profiler_startTime.find(s)->second;
00083 }
00084 }
|
|
||||||||||||||||||||||||
|
Definition at line 57 of file ASprite.cpp. Referenced by BattleGroup::render(), BattleEntry::renderEnvironment(), and renderParticleList().
00058 {
00059 AS.sprite_renderList.push_back( SpriteRenderRequestEntry(tex,blendMode,pos,multiplier,size) );
00060 }
|
|
|
this returns you an output stream that you can write stuffs to they will be displayed on the in-game console window if it is set to visible
Definition at line 629 of file ASys.cpp. Referenced by NetworkData::addData(), Globals::MessagesReceived::addMessage(), City::deleteJetGuard(), BattleGroup::destroyUnit(), doGameLoop(), BattleGroup::fire(), getGameTick(), BattleEntry::initBattle(), BattleEntry::isBattleFinished(), NetworkSubsystem::loadNetworkData(), mesh_init(), net_connectToServer(), net_recv(), Overhead::overhead_init(), Overhead::overhead_update(), Helper::playerColorToPlayerNumber(), Overhead::playerStrength(), Overhead::printAllMilitaryUnits(), NetworkSubsystem::processNetworkData(), BattleEntry::processQueuedInput(), profiler_render(), NetworkSubsystem::receiveNetworkData(), terrain_getHeight(), City::update(), and Overhead::updateBattleEntries().
00630 {
00631 assert(AS.pConsoleStream);
00632 return *(AS.pConsoleStream);
00633 }
|
|
|
this function must be called before sys_go(); this will log all subsequent output to the console to the specified logfile
Definition at line 617 of file ASys.cpp. Referenced by main_init().
00618 {
00619 // make sure we wipe out all previous content in the file if it already exists
00620 AS.pConsoleLogFile = new ofstream(filename.c_str());
00621 (*AS.pConsoleLogFile) << "Clear Log" << endl;
00622 AS.pConsoleLogFile->close();
00623 delete AS.pConsoleLogFile;
00624
00625 // open up the file for writting
00626 AS.pConsoleLogFile = new ofstream(filename.c_str());
00627 }
|
|
|
quickly update the game state 'times' times. this is quivalent to fast forwarding the game by roughly 'times'/62.5 seconds
Definition at line 656 of file ASys.cpp. Referenced by Overhead::overhead_render().
00657 {
00658 assert(times>=0 && times<1000);
00659 AS.fastForwardAmount = times;
00660 }
|
|
|
flushes all texts sent to consol eto log file (if any)
Definition at line 635 of file ASys.cpp. References MAX_CONSOLE_LINES. Referenced by NetworkData::addData(), City::deleteJetGuard(), getGameTick(), NetworkSubsystem::processNetworkData(), BattleEntry::processQueuedInput(), NetworkSubsystem::receiveNetworkData(), and sys_terminate().
00636 {
00637 if(!AS.pConsoleLogFile) return;
00638
00639 istringstream in(AS.pConsoleStream->str());
00640 string line;
00641 while(in)
00642 {
00643 getline( in, line );
00644 if(line!="" || in)
00645 {
00646 AS.consoleLineIndex = (AS.consoleLineIndex+1) % MAX_CONSOLE_LINES;
00647 AS.consoleLines[ AS.consoleLineIndex ] = line;
00648 (*AS.pConsoleLogFile) << line << endl;
00649 }
00650 }
00651
00652 delete AS.pConsoleStream;
00653 AS.pConsoleStream = new ostringstream();
00654 }
|
|
|
get current time in ms
Definition at line 662 of file ASys.cpp. References DWORD. Referenced by doGameLoop(), Typer::input(), and profiler_reset().
00663 {
00664 LARGE_INTEGER tick;
00665 static LARGE_INTEGER freq = {0};
00666 static bool inited = false;
00667 if (!inited)
00668 {
00669 inited = true;
00670 QueryPerformanceFrequency( &freq );
00671 }
00672 QueryPerformanceCounter( &tick );
00673 return (DWORD)((tick.QuadPart * 1000) / freq.QuadPart);
00674 }
|
|
|
Definition at line 707 of file ASys.cpp.
00708 {
00709 return AS.hWnd;
00710 }
|
|
|
let the program runs. This function doesn't return (until sys_terminate())
Definition at line 534 of file ASys.cpp. References createRenderingDevice(), createWindow(), displayLoadingScreen(), doGameLoop(), flare_init(), input_init(), MAX_LOCAL_RANDON_FLOAT, MAX_LOCAL_RANDON_NUM, mesh_init(), overlay_init(), sprite_init(), sys_randFloat(), sys_shutdown(), and Vec2D. Referenced by WinMain().
00535 {
00536 createWindow();
00537 createRenderingDevice();
00538
00539 // init all major components
00540 input_init();
00541 overlay_init();
00542
00543 // init all sub components
00544 // init console
00545 AS.showConsole = true;
00546 AS.showFPS = false;
00547 AS.pConsoleStream = new ostringstream();
00548 AS.consoleLineIndex = 0;
00549
00550 AS.camera_screenSize = 1.0f;
00551 AS.camera_vibratePos = 0.0f;
00552 AS.camera_vibrateSpeed = 0.0f;
00553
00554 AS.input_mouseIdleTickCount = 0;
00555 AS.input_lastTickMousePos = Vec2D(0,0);
00556
00557 // init game loop control counters
00558 AS.lastCountResetMS = 0;
00559 AS.updateCount = 0;
00560 AS.updateRate = 0;
00561 AS.renderCount = 0;
00562 AS.renderRate = 0;
00563 AS.excessCount = 0;
00564 AS.excessRate = 0;
00565 AS.renderNumber = 0;
00566 AS.fastForwardAmount = 0;
00567
00568 // specific to this game
00569 displayLoadingScreen();
00570
00571 // networking
00572 AS.net_isInit = false;
00573
00574 for(int i=0; i<MAX_LOCAL_RANDON_NUM; i++) // local random number generator
00575 AS.res_localRandomNums.push_back( rand()%256 );
00576 for(int i=0; i<MAX_LOCAL_RANDON_FLOAT; i++ )
00577 AS.res_localRandomFloats.push_back( sys_randFloat() );
00578 AS.res_localRandomNumIndex = 0;
00579 AS.res_localRandomFloatIndex = 0;
00580
00581 // user-defined initialization
00582 (AS.initFunc)();
00583
00584 mesh_init();
00585 flare_init();
00586 sprite_init();
00587
00588 // Let it all go
00589 try
00590 {
00591 doGameLoop();
00592 }
00593 catch(TerminateNormally e)
00594 {
00595 sys_shutdown();
00596 if(AS.shutdownFunc) (AS.shutdownFunc)();
00597 return;
00598 }
00599 }
|
|
||||||||||||||||||||||||
|
setup the AEngine. You should call this before doing anything else hInst is passed to you by WinMain. Just pass it along to this function note that not all modes can be supported by your video card try standard things such as 800x600x16bit or 1024x768x32bit
Definition at line 35 of file ASys.cpp. References Vec3D. Referenced by WinMain().
00036 {
00037 AS.hInst = hInst;
00038 AS.windowWidth = width;
00039 AS.windowHeight = height;
00040 AS.colorDepth = colorDepth;
00041 AS.isFullScreen = fullScreen;
00042 AS.initFunc = NULL;
00043 AS.updateFunc = NULL;
00044 AS.renderFunc = NULL;
00045 AS.shutdownFunc = NULL;
00046 AS.pConsoleLogFile = NULL;
00047 AS.vshader_terrain = NULL;
00048
00049 AS.camera_pos = Vec3D( 3.0f, 0.0f, 3.0f );
00050 AS.camera_target = Vec3D( 0.0f, 0.0f, 0.0f );
00051 D3DXMatrixIdentity(& (AS.camera_world2projMatrix) );
00052 AS.skipRate = 0;
00053
00054 //unsigned int newFlags = _RC_DOWN | _PC_64;
00055 //unsigned int mask = _MCW_RC | _MCW_PC;
00056 //_controlfp(newFlags,mask);
00057 }
|
|
|
Definition at line 701 of file ASys.cpp. References MAX_LOCAL_RANDON_FLOAT. Referenced by Overhead::overheadRender().
00702 {
00703 AS.res_localRandomFloatIndex = (AS.res_localRandomFloatIndex + 1) % MAX_LOCAL_RANDON_FLOAT;
00704 return AS.res_localRandomFloats[ AS.res_localRandomFloatIndex ];
00705 }
|
|
|
Definition at line 695 of file ASys.cpp. References MAX_LOCAL_RANDON_NUM. Referenced by Overhead::overheadRender(), Sound::playRandomSound(), playVoiceContact(), playVoicePanick(), and playVoiceStress().
00696 {
00697 AS.res_localRandomNumIndex = (AS.res_localRandomNumIndex + 1) % MAX_LOCAL_RANDON_NUM;
00698 return AS.res_localRandomNums[ AS.res_localRandomNumIndex ];
00699 }
|
|
|
Definition at line 690 of file ASys.cpp. Referenced by Globals::ArtWork::ArtWork(), BattleGroup::destroyUnit(), BattleJets::fireAntiAirMissiles(), BattleJets::fireAntiSurfaceMissiles(), BattleJets::flyTo(), MilitaryUnit::move(), sys_go(), and BattleJets::takeHit().
00691 {
00692 return (rand()&0x0ff) / 128.0f - 1.0f;
00693 }
|
|
|
Definition at line 685 of file ASys.cpp. Referenced by Globals::ArtWork::ArtWork(), City::changeOwner(), BattleGroup::destroyUnit(), BattleGroup::fire(), BattleGroup::fireAntiAir(), BattleJets::fireAntiAirMissiles(), BattleJets::fireAntiSurfaceMissiles(), Jet::move(), NetworkSubsystem::processNetworkData(), BattleJets::takeHit(), BattleEntry::updateDebris(), and updateMultiplayMenu().
00686 {
00687 return rand();
00688 }
|
|
|
set call-back functions so the engine knows how to init, update the game state, render it, and shut down
Definition at line 64 of file ASys.cpp. Referenced by WinMain().
00065 {
00066 AS.initFunc = f;
00067 }
|
|
|
use these functions instead of the builtin rand, srand so we can log and keep track of what's going on
Definition at line 678 of file ASys.cpp. References MAX_LOCAL_RANDON_FLOAT, and MAX_LOCAL_RANDON_NUM. Referenced by processIncomingMessages().
00679 {
00680 srand( (unsigned int)seed );
00681 AS.res_localRandomNumIndex = seed % MAX_LOCAL_RANDON_NUM;
00682 AS.res_localRandomFloatIndex = seed % MAX_LOCAL_RANDON_FLOAT;
00683 }
|
|
|
Definition at line 74 of file ASys.cpp. Referenced by WinMain().
00075 {
00076 AS.renderFunc = f;
00077 }
|
|
|
Definition at line 79 of file ASys.cpp. Referenced by WinMain().
00080 {
00081 AS.shutdownFunc = f;
00082 }
|
|
|
rate=0 means try never to skip any frame. rate=1 means render every other frame
Definition at line 59 of file ASys.cpp. Referenced by main_init().
00060 {
00061 AS.skipRate = rate;
00062 }
|
|
|
Definition at line 69 of file ASys.cpp. Referenced by WinMain().
00070 {
00071 AS.updateFunc = f;
00072 }
|
|
|
whether or not to display the console window
Definition at line 612 of file ASys.cpp. Referenced by main_init().
00613 {
00614 AS.showConsole = show;
00615 }
|
|
|
whether to show the frame rate in the top-right corner
Definition at line 607 of file ASys.cpp.
00608 {
00609 AS.showFPS = show;
00610 }
|
|
|
terminate the application. This function never returns
Definition at line 601 of file ASys.cpp. References sys_flushConsole(). Referenced by Overhead::overhead_update(), and updateMainMenu().
00602 {
00603 sys_flushConsole();
00604 throw TerminateNormally();
00605 }
|
|
||||||||||||||||
|
Definition at line 268 of file ATerrain.cpp. References TerrainEntry::sizeX, TerrainEntry::sizeY, sys_console(), TERR_COLS, TERR_ROWS, triArea(), Vec2D, and TerrainEntry::zMap. Referenced by Globals::ArtWork::ArtWork(), BattleGroup::destroyUnit(), BattleGroup::drawOutlineBox(), BattleGroup::fire(), BattleGroup::fireAntiAir(), BattleJets::flyTo(), BattleEntry::inputIssueJetsCommand(), BattleGroup::isContain2DPoint(), MilitaryUnit::move(), BattleJets::orderToBomb(), BattleGroup::render(), BattleEntry::renderGroups(), City::update(), and BattleEntry::updateDebris().
00269 {
00270 // idea : return the weighted average height of the closest 4 pts
00271 // weight = area of triangle formed
00272 assert(terrain>=0 && terrain<(int)AS.res_terrains.size());
00273 TerrainEntry &t = AS.res_terrains[terrain];
00274
00275 FLOAT gridSizeX = t.sizeX / (TERR_COLS);
00276 FLOAT gridSizeY = t.sizeY / (TERR_ROWS);
00277 int i = (int)( (x+t.sizeX/2) / gridSizeX );
00278 int j = (int)( (y+t.sizeY/2) / gridSizeY );
00279 if( !(i>=0 && j>=0 && i<TERR_COLS-1 && j<TERR_ROWS-1) )
00280 {
00281 sys_console() << "Warning : terrain_getHeight out of terrain area" << endl;
00282 return 0;
00283 }
00284
00285 Vec2D pMid(x,y);
00286 Vec2D p0( t.sizeX*( i*1.0f/TERR_COLS -0.5f), t.sizeY*( j*1.0f/TERR_ROWS -0.5f) );
00287 Vec2D p1( t.sizeX*((i+1)*1.0f/TERR_COLS -0.5f), t.sizeY*( j*1.0f/TERR_ROWS -0.5f) );
00288 Vec2D p2( t.sizeX*((i+1)*1.0f/TERR_COLS -0.5f), t.sizeY*((j+1)*1.0f/TERR_ROWS -0.5f) );
00289 Vec2D p3( t.sizeX*( i*1.0f/TERR_COLS -0.5f), t.sizeY*((j+1)*1.0f/TERR_ROWS -0.5f) );
00290
00291 FLOAT tri0 = triArea( p0, p1, pMid );
00292 FLOAT tri1 = triArea( p1, p2, pMid );
00293 FLOAT tri2 = triArea( p2, p3, pMid );
00294 FLOAT tri3 = triArea( p3, p0, pMid );
00295
00296 FLOAT weight0 = tri1*tri2, weight1=tri2*tri3,
00297 weight2 = tri3*tri0, weight3=tri0*tri1;
00298 FLOAT sum = t.zMap[j][i] *weight0 + t.zMap[j][i+1]*weight1
00299 + t.zMap[j+1][i+1]*weight2 + t.zMap[j+1][i]*weight3;
00300 FLOAT height = sum/(weight0+weight1+weight2+weight3);
00301 //return ((int)(height*10))/10.0f;
00302 return height;
00303 }
|
|
||||||||||||||||||||
|
Definition at line 181 of file ATerrain.cpp. Referenced by Overhead::overheadRender(), and BattleEntry::renderEnvironment().
00182 {
00183 assert(terrain>=0 && terrain<(int)AS.res_terrains.size());
00184 AS.res_terrains[terrain].doRender = true;
00185 AS.res_terrains[terrain].texLow = texLow;
00186 AS.res_terrains[terrain].texHigh = texHigh;
00187 AS.res_terrains[terrain].texNormal = texNormal;
00188 }
|
1.3-rc2