fixed compilation under windows

- crashes sometimes for no obvious reason when loading fonts
This commit is contained in:
2011-05-04 18:33:44 +02:00
parent b5c4ef359f
commit c2ca0a1a4d
18 changed files with 100 additions and 41 deletions
+1 -3
View File
@@ -38,9 +38,7 @@ void Controller::ResetPlayerEntity () {
Engine::EntityBase *player_entity = GetModel()->GetEntity(GetModel()->GetPlayerEntityId());
player_entity->mPhysicState->mAngleVelocity = 0.;
int i;
for (i = 0; i < EntityControllerMaxKeyStates; i++)
player_entity->UnsetControllerKeyState(i);
player_entity->ResetControllerKeyState();
}
// We definitely have to reset the player entity id
+8 -7
View File
@@ -160,19 +160,20 @@ void Model::Process () {
}
unsigned int Model::InitLevelList () {
boost::filesystem::path level_dir_path;
std::string level_dir_name = Engine::GetResourceFullPath("/data/levels/");
Engine::LogDebug ("Searching for levels in %s", level_dir_name.c_str());
mLevelList.clear();
boost::filesystem::path level_dir(level_dir_name);
if (!boost::filesystem::exists(level_dir)) {
Engine::LogError ("Could not init level list: \todo %s does not exist!");
if (!boost::filesystem::exists(level_dir.file_string())) {
Engine::LogError ("Could not init level list: %s does not exist!", level_dir.filename());
}
if (!boost::filesystem::is_directory(level_dir)) {
Engine::LogError ("Could not init level list: \todo %s is not a directory!");
Engine::LogError ("Could not init level list: %s is not a directory!", level_dir_name.c_str());
}
boost::filesystem::directory_iterator end_iter;
@@ -184,8 +185,8 @@ unsigned int Model::InitLevelList () {
level_relative_path += dir_iter->path().filename();
// check whether we found an official level
std::string map_name (level_relative_path);
map_name = map_name.substr(map_name.rfind ('/') + 1, map_name.size());
std::string map_name (dir_iter->filename());
if (mLevelHashes.find(map_name) == mLevelHashes.end()) {
Engine::LogDebug ("Skipping unofficial level %s", std::string(level_relative_path).c_str());
continue;
@@ -559,7 +560,7 @@ void Model::SubmitHighscoreEntry (const std::string &name, const unsigned int po
int Model::DoLoadLevel (const char* filename) {
// verify the hash of the map
std::string map_name (filename);
map_name = map_name.substr(map_name.rfind ('/') + 1, map_name.size());
map_name = boost::filesystem::path(map_name).filename();
std::string map_hash = sha256_hash_file (filename);
if (map_hash != mLevelHashes[map_name]) {
Engine::LogMessage ("Map verification for file %s failed!", map_name.c_str());
+11 -4
View File
@@ -116,27 +116,34 @@ int main (int argc, char* argv[]) {
SetLogPrintLevel (Engine::LogLevelWarning);
std::string user_path = ".";
std::string game_data_path = ".";
std::string user_path = "";
std::string game_data_path = "";
#ifndef WIN32
user_path = create_user_path();
game_data_path = find_game_data_dir();
#endif
boost::filesystem::path cpath = boost::filesystem::initial_path<boost::filesystem::path>();
std::cerr << "cwd: " << cpath.string() << std::endl;
// we assume the user path to be local folder
std::string log_file_path = user_path;
log_file_path += "/game.log";
user_path = boost::filesystem::path(cpath.string() + user_path).file_string();
game_data_path = boost::filesystem::path(cpath.string() + game_data_path).file_string();
log_file_path = boost::filesystem::path (cpath.string() + log_file_path).file_string();
cout << "User Data Dir = " << user_path << endl;
engine.SetUserDataPath (user_path);
Engine::SetLogFilename (log_file_path.c_str());
Engine::SetLogFilename (log_file_path);
engine.SetGameDataPath (game_data_path);
cout << "Game Data Dir = " << game_data_path << endl;
if (engine.Init (argc, argv) != 0) {
if (engine.Init (argc, argv) != 0) {
cout << "Could not start engine!" << endl;
exit (-1);
}