1
0
forked from 0ad/0ad

all functions called via delay-load mechanism now return int (allows closures that can interrupt themselves when time is up)

This was SVN commit r2231.
This commit is contained in:
janwas 2005-05-03 21:36:57 +00:00
parent f34cd1ee08
commit f0e311440e
13 changed files with 29 additions and 21 deletions

View File

@ -74,7 +74,7 @@ CGameView::~CGameView()
} }
void CGameView::Initialize(CGameAttributes *pAttribs) int CGameView::Initialize(CGameAttributes *pAttribs)
{ {
CConfigValue* cfg; CConfigValue* cfg;
@ -92,11 +92,12 @@ void CGameView::Initialize(CGameAttributes *pAttribs)
getViewParameter( "view.zoom.wheel.speed", m_ViewZoomSensitivityWheel ); getViewParameter( "view.zoom.wheel.speed", m_ViewZoomSensitivityWheel );
getViewParameter( "view.zoom.smoothness", m_ViewZoomSmoothness ); getViewParameter( "view.zoom.smoothness", m_ViewZoomSmoothness );
getViewParameter( "view.snap.smoothness", m_ViewSnapSmoothness ); getViewParameter( "view.snap.smoothness", m_ViewSnapSmoothness );
#undef getViewParameter
if( ( m_ViewZoomSmoothness < 0.0f ) || ( m_ViewZoomSmoothness > 1.0f ) ) m_ViewZoomSmoothness = 0.02f; if( ( m_ViewZoomSmoothness < 0.0f ) || ( m_ViewZoomSmoothness > 1.0f ) ) m_ViewZoomSmoothness = 0.02f;
if( ( m_ViewSnapSmoothness < 0.0f ) || ( m_ViewSnapSmoothness > 1.0f ) ) m_ViewSnapSmoothness = 0.02f; if( ( m_ViewSnapSmoothness < 0.0f ) || ( m_ViewSnapSmoothness > 1.0f ) ) m_ViewSnapSmoothness = 0.02f;
#undef getViewParameter return 0;
} }
@ -112,9 +113,9 @@ void CGameView::RegisterInit(CGameAttributes *pAttribs)
RegMemFun1(this, &CGameView::Initialize, pAttribs, L"CGameView init", 1); RegMemFun1(this, &CGameView::Initialize, pAttribs, L"CGameView init", 1);
// previously done by CGameView::InitResources // previously done by CGameView::InitResources
RegMemFun(g_TexMan.GetSingletonPtr(), &CTextureManager::LoadTerrainTextures, L"LoadTerrainTextures", 17); RegMemFun(g_TexMan.GetSingletonPtr(), &CTextureManager::LoadTerrainTextures, L"LoadTerrainTextures", 80);
RegMemFun(g_ObjMan.GetSingletonPtr(), &CObjectManager::LoadObjects, L"LoadObjects", 1063); RegMemFun(g_ObjMan.GetSingletonPtr(), &CObjectManager::LoadObjects, L"LoadObjects", 1);
RegMemFun(g_Renderer.GetSingletonPtr(), &CRenderer::LoadAlphaMaps, L"LoadAlphaMaps", 36); RegMemFun(g_Renderer.GetSingletonPtr(), &CRenderer::LoadAlphaMaps, L"LoadAlphaMaps", 40);
} }

View File

@ -61,7 +61,7 @@ public:
~CGameView(); ~CGameView();
void RegisterInit(CGameAttributes *pAttribs); void RegisterInit(CGameAttributes *pAttribs);
void Initialize(CGameAttributes *pGameAttributes); int Initialize(CGameAttributes *pGameAttributes);
// Update: Update all the view information (i.e. rotate camera, scroll, // Update: Update all the view information (i.e. rotate camera, scroll,
// whatever). This will *not* change any World information - only the // whatever). This will *not* change any World information - only the

View File

@ -169,9 +169,10 @@ void CObjectManager::DeleteObject(CObjectEntry* entry)
} }
void CObjectManager::LoadObjects() int CObjectManager::LoadObjects()
{ {
AddObjectType(""); AddObjectType("");
return 0;
} }

View File

@ -57,7 +57,7 @@ public:
CObjectManager(); CObjectManager();
~CObjectManager(); ~CObjectManager();
void LoadObjects(); int LoadObjects();
void AddObjectType(const char* name); void AddObjectType(const char* name);

View File

@ -97,7 +97,7 @@ void CTextureManager::DeleteTexture(CTextureEntry* entry)
delete entry; delete entry;
} }
void CTextureManager::LoadTerrainTextures(int terraintype,const char* fileext_filter) void CTextureManager::LoadTerrainTexturesImpl(int terraintype,const char* fileext_filter)
{ {
CStr pathname("art/textures/terrain/types/"); CStr pathname("art/textures/terrain/types/");
pathname+=m_TerrainTextures[terraintype].m_Name; pathname+=m_TerrainTextures[terraintype].m_Name;
@ -135,7 +135,7 @@ void CTextureManager::BuildTerrainTypes()
} }
void CTextureManager::LoadTerrainTextures() int CTextureManager::LoadTerrainTextures()
{ {
// find all the terrain types by directory name // find all the terrain types by directory name
BuildTerrainTypes(); BuildTerrainTypes();
@ -143,7 +143,9 @@ void CTextureManager::LoadTerrainTextures()
// now iterate through terrain types loading all textures of that type // now iterate through terrain types loading all textures of that type
for (uint i=0;i<m_TerrainTextures.size();i++) { for (uint i=0;i<m_TerrainTextures.size();i++) {
for (uint j=0;j<ARRAY_SIZE(SupportedTextureFormats);j++) { for (uint j=0;j<ARRAY_SIZE(SupportedTextureFormats);j++) {
LoadTerrainTextures(i,SupportedTextureFormats[j]); LoadTerrainTexturesImpl(i,SupportedTextureFormats[j]);
} }
} }
return 0;
} }

View File

@ -29,7 +29,7 @@ public:
CTextureManager(); CTextureManager();
~CTextureManager(); ~CTextureManager();
void LoadTerrainTextures(); int LoadTerrainTextures();
void AddTextureType(const char* name); void AddTextureType(const char* name);
@ -42,7 +42,7 @@ public:
std::vector<STextureType> m_TerrainTextures; std::vector<STextureType> m_TerrainTextures;
private: private:
void LoadTerrainTextures(int terraintype,const char* fileext); void LoadTerrainTexturesImpl(int terraintype,const char* fileext);
void BuildTerrainTypes(); void BuildTerrainTypes();
}; };

View File

@ -22,7 +22,7 @@ CLightEnv g_LightEnv;
void CWorld::Initialize(CGameAttributes *pAttribs) void CWorld::Initialize(CGameAttributes *pAttribs)
{ {
// TODO: Find a better way of handling these global things // TODO: Find a better way of handling these global things
ONCE(RegMemFun(CBaseEntityCollection::GetSingletonPtr(), &CBaseEntityCollection::loadTemplates, L"LoadTemplates", 960)); ONCE(RegMemFun(CBaseEntityCollection::GetSingletonPtr(), &CBaseEntityCollection::loadTemplates, L"LoadTemplates", 30));
// Load the map, if one was specified // Load the map, if one was specified
if (pAttribs->m_MapFile.Length()) if (pAttribs->m_MapFile.Length())

View File

@ -1153,7 +1153,7 @@ inline void CopyTriple(unsigned char* dst,const unsigned char* src)
// LoadAlphaMaps: load the 14 default alpha maps, pack them into one composite texture and // LoadAlphaMaps: load the 14 default alpha maps, pack them into one composite texture and
// calculate the coordinate of each alphamap within this packed texture .. need to add // calculate the coordinate of each alphamap within this packed texture .. need to add
// validation that all maps are the same size // validation that all maps are the same size
void CRenderer::LoadAlphaMaps() int CRenderer::LoadAlphaMaps()
{ {
Handle textures[NumAlphaMaps]; Handle textures[NumAlphaMaps];
@ -1251,6 +1251,8 @@ void CRenderer::LoadAlphaMaps()
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
delete[] data; delete[] data;
return 0;
} }
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -207,7 +207,7 @@ public:
bool IsTextureTransparent(CTexture* texture); bool IsTextureTransparent(CTexture* texture);
// load the default set of alphamaps; return false if any alphamap fails to load, true otherwise // load the default set of alphamaps; return false if any alphamap fails to load, true otherwise
void LoadAlphaMaps(); int LoadAlphaMaps();
void UnloadAlphaMaps(); void UnloadAlphaMaps();

View File

@ -27,10 +27,11 @@ static void LoadFileThunk( const char* path, const vfsDirEnt* ent, void* context
this_->LoadFile(path); this_->LoadFile(path);
} }
void CBaseEntityCollection::loadTemplates() int CBaseEntityCollection::loadTemplates()
{ {
// Load all files in entities/ and its subdirectories. // Load all files in entities/ and its subdirectories.
THROW_ERR( VFSUtil::EnumDirEnts( "entities/", "*.xml", true, LoadFileThunk, this ) ); THROW_ERR( VFSUtil::EnumDirEnts( "entities/", "*.xml", true, LoadFileThunk, this ) );
return 0;
} }
CBaseEntity* CBaseEntityCollection::getTemplate( CStrW name ) CBaseEntity* CBaseEntityCollection::getTemplate( CStrW name )

View File

@ -35,7 +35,7 @@ class CBaseEntityCollection : public Singleton<CBaseEntityCollection>
public: public:
~CBaseEntityCollection(); ~CBaseEntityCollection();
CBaseEntity* getTemplate( CStrW entityType ); CBaseEntity* getTemplate( CStrW entityType );
void loadTemplates(); int loadTemplates();
void LoadFile( const char* path ); void LoadFile( const char* path );
// Create a list of the names of all base entities, excluding template_*, // Create a list of the names of all base entities, excluding template_*,

View File

@ -33,11 +33,12 @@ CSimulation::~CSimulation()
g_SinglePlayerTurnManager=NULL; g_SinglePlayerTurnManager=NULL;
} }
void CSimulation::Initialize(CGameAttributes *pAttribs) int CSimulation::Initialize(CGameAttributes *pAttribs)
{ {
m_pTurnManager->Initialize(m_pGame->GetNumPlayers()); m_pTurnManager->Initialize(m_pGame->GetNumPlayers());
g_EntityManager.InitializeAll(); g_EntityManager.InitializeAll();
return 0;
} }

View File

@ -34,7 +34,7 @@ public:
{ return m_pTurnManager; } { return m_pTurnManager; }
void RegisterInit(CGameAttributes *pGameAttributes); void RegisterInit(CGameAttributes *pGameAttributes);
void Initialize(CGameAttributes *pGameAttributes); int Initialize(CGameAttributes *pGameAttributes);
// Perform all CSimulation updates for the specified elapsed time. // Perform all CSimulation updates for the specified elapsed time.
void Update(double frameTime); void Update(double frameTime);