changeset 1554:e303d8a9bcdc

Merge
author Grumpy7
date Sat, 07 Sep 2013 21:14:48 +0200
parents b98812ead5d9 (current diff) 9a6567c6c76c (diff)
children 9c4cf5b07e98
files Actor.cpp Player.cpp
diffstat 70 files changed, 1047 insertions(+), 1253 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Actor.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,9 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
-
 #include "mm7_data.h"
 #include "DecalBuilder.h"
 
@@ -1826,7 +1823,7 @@
     v41.vDirection.y = (signed __int64)(1.0 / v33 * v43 * 65536.0);
     v41.vDirection.z = (signed __int64)(1.0 / v33 * a4a * 65536.0);
     v41.uDistance = (signed __int64)v33;
-    v41.uDistanceXZ = (signed __int64)sqrt(outy2 + outx2);
+    v41.uDistanceXZ = sqrt(outy2 + outx2);
     v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v42, (signed __int64)v43);
     v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a);
   }
@@ -3970,12 +3967,12 @@
         v9 = v6 - stru_721530.normal.y,
         v10 = stru_721530.prolly_normal_d + v4,
         v17 = stru_721530.prolly_normal_d + v4,
-        v11 = (v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16,
+        v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16,
         v18 = v8,
         v19 = v9,
-        abs((v8 * stru_721530.field_58.y - v9 * stru_721530.field_58.x) >> 16) > v10)
-    || (v12 = (v18 * stru_721530.field_58.x + v19 * stru_721530.field_58.y) >> 16, v12 <= 0)
-    || (signed int)(((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z )
+        abs((v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16) > v10)
+    || (v12 = (v18 * stru_721530.direction.x + v19 * stru_721530.direction.y) >> 16, v12 <= 0)
+    || (signed int)(((unsigned __int64)(stru_721530.direction.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z )
   {
 LABEL_25:
     result = 0;
@@ -4063,7 +4060,7 @@
 	//int v61; // [sp-14h] [bp-C4h]@168
 	//AIDirection *v62; // [sp-14h] [bp-C4h]@213
 	//signed int v63; // [sp-14h] [bp-C4h]@216
-	unsigned int v64; // [sp-14h] [bp-C4h]@219
+	//unsigned int v64; // [sp-14h] [bp-C4h]@219
 	unsigned int v65; // [sp-10h] [bp-C0h]@144
 	char v66; // [sp-10h] [bp-C0h]@147
 	//AIDirection *v67; // [sp-10h] [bp-C0h]@167
@@ -4194,19 +4191,19 @@
 				++v14;
 			}
 			while ( v13 < 22 );*/
-			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 )
+			if (pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0)
 			//&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12
 			// || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) )
 				pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
-			if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 )
+			if (pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0)
 				pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
 			// not sure
-			else  if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 )
+			else if (pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0)
 				pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType;
 			
-			if ((signed __int64)pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 
-				|| (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
-				continue;
+			if (pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 ||
+				pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
+		      continue;
 			
 			//v15 = pMiscTimer->uTimeElapsed;
 			//v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime;
@@ -4408,7 +4405,7 @@
 					pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
 			}
 
-			if ( (signed __int64)pActor->pActorBuffs[4].uExpireTime > 0 )
+			if (pActor->pActorBuffs[4].uExpireTime > 0)
 			{
 				if ( (signed int)v36 >= 10240 )
 				{
@@ -4430,7 +4427,7 @@
 				{
 					if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 					{
-						Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333),	&pDir);
+						Actor::AI_Stand(actor_id, target_pid, pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333,	&pDir);
 					}
 					else
 					{
@@ -4477,21 +4474,19 @@
 							}
 							else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 							}
 							else
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 								if ( v80 * 307.2 > (double)v81 )
 								{
-									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 								}
 								else
 								{
-									Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+									Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
 								}
 							}
 						}
@@ -4503,9 +4498,8 @@
 								{
 									if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 									{
-										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-										v64 = (signed __int64)v47;
-										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+										v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 									}
 									else
 									{
@@ -4515,9 +4509,8 @@
 								}
 								else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 								{
-									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+									v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 								}
 								else
 								{
@@ -4530,9 +4523,8 @@
 							}
 							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 							}
 							else
 							{
@@ -4559,14 +4551,13 @@
 							}
 							else if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 							}
 							else
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
 							}
 						}
 						else
@@ -4577,9 +4568,8 @@
 								{
 									if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 									{
-										v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-										v64 = (signed __int64)v47;
-										Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+										v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+										Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 									}
 									else
 									{
@@ -4588,9 +4578,8 @@
 								}
 								else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 								{
-									v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-									v64 = (signed __int64)v47;
-									Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+									v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+									Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 								}
 								else
 								{
@@ -4600,9 +4589,8 @@
 							}
 							else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 							{
-								v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-								v64 = (signed __int64)v47;
-								Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+								v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+								Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 							}
 							else
 							{
@@ -4638,8 +4626,7 @@
 					v58 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 					memcpy(&v74, v57, sizeof(v74));
 					memcpy(&pDir, &v74, sizeof(pDir));
-					v64 = (signed __int64)v58;
-					Actor::AI_Stand(actor_id, 4, v64, &pDir);
+					Actor::AI_Stand(actor_id, 4, v58, &pDir);
 				}				
 			}
 			else if ( !pActor->pMonsterInfo.uMissleAttack2Type )
@@ -4650,9 +4637,8 @@
 					{
 						if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 						{
-							v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-							v64 = (signed __int64)v47;
-							Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+							v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+							Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 						}
 						else
 						{
@@ -4661,9 +4647,8 @@
 					}
 					else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
 					{
-						v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-						v64 = (signed __int64)v47;
-						Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+						v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+						Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 					}
 					else
 					{
@@ -4673,9 +4658,8 @@
 				}
 				else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 )
 				{
-					v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
-					v64 = (signed __int64)v47;
-					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
+					v47 = pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
+					Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 				}
 				else
 				{
@@ -4686,14 +4670,9 @@
 			{
 				v47 = (double)(signed int)pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333;
 				if ( v80 * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY )
-				{
-					v64 = (signed __int64)v47;
-					Actor::AI_Stand(actor_id, target_pid, v64, &pDir);
-				}
+					Actor::AI_Stand(actor_id, target_pid, v47, &pDir);
 				else
-				{
-					Actor::AI_Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir);
-				}
+					Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, &pDir);
 			}
 			else
 			{
@@ -4711,7 +4690,6 @@
 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive)
 {
   unsigned int uAliveActors; // eax@6
-  int v5; // ecx@10
   unsigned int uTotalActors; // [sp+0h] [bp-4h]@1
 
   uTotalActors = 0;
@@ -4739,12 +4717,11 @@
   {
     uAliveActors = SearchAliveActors(&uTotalActors);
   }
-  v5 = 0;
-  if ( uNumAlive )
-    LOBYTE(v5) = (signed int)uAliveActors >= (signed int)uNumAlive;
+
+  if (uNumAlive)
+    return uAliveActors >= uNumAlive;
   else
-    LOBYTE(v5) = uTotalActors == uAliveActors;
-  return v5;
+    return uTotalActors == uAliveActors;
 }
 //----- (00408B54) --------------------------------------------------------
 unsigned int SearchActorByID(unsigned int *pTotalActors, unsigned int a2)
@@ -5029,7 +5006,7 @@
   if (pMonster->IsNotAlive())
     return;
 
-  BYTE1(pMonster->uAttributes) |= 0xC0u;
+  pMonster->uAttributes |= 0xC000;
   if ( pMonster->uAIState == Fleeing )
     pMonster->uAttributes |= 0x20000u;
   //v57 = 0;
@@ -5424,7 +5401,7 @@
   monster_id = a1;
   x_ = x;
   v15 = a1;
-  if ( (signed int)uNumActors < 500
+  if (uNumActors < 500
     && ((signed int)pAllocator->uBigBufferSizeAligned >> 10) - ((signed int)pAllocator->uNextFreeOffsetInBigBuffer >> 10) >= 2000 )
   {
     v16 = 0;
--- a/Allocator.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Allocator.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -6,6 +6,7 @@
 #include <stdio.h>
 
 #include "Allocator.h"
+#include "ErrorHandling.h"
 
 #include "mm7_data.h"
 
@@ -13,6 +14,7 @@
 
 Allocator *pAllocator; // idb
 
+int aborting_app = false; // weak
 
 
 
@@ -24,9 +26,8 @@
 //----- (00426755) --------------------------------------------------------
 void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName)
 {
+  Assert(!pPrevPtrValue, "PrevPtrValue != 0");
 
-  if ( pPrevPtrValue && !aborting_app )
-	  AbortWithError();
   if (!uSize)
 	  return 0;
   return malloc(uSize);
--- a/Arcomage.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Arcomage.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -3,7 +3,6 @@
 #endif
 
 #include <string>
-#include <assert.h>
 
 #include "Render.h"
 #include "Arcomage.h"
--- a/AudioPlayer.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/AudioPlayer.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -3,7 +3,6 @@
 #endif
 
 #include <string>
-#include <assert.h>
 
 #include "mm7_data.h"
 #include "VideoPlayer.h"
@@ -22,6 +21,7 @@
 #include "MapInfo.h"
 #include "GUIWindow.h"
 #include "Log.h"
+#include "ErrorHandling.h"
 
 #include "Bink_Smacker.h"
 
@@ -264,7 +264,8 @@
     a2 = v14->uDecompressedSize;
     v16 = a2;
     if ( (signed int)a2 > uBufferSizeLeft )
-      Abortf("Sound %s is size %i bytes, sound buffer size is %i bytes", Args, a2, uBufferSizeLeft);
+      Error("Sound %s is size %i bytes, sound buffer size is %i bytes", Args, a2, uBufferSizeLeft);
+
     SetFilePointer(pAudioPlayer->hAudioSnd, v14->uFileOffset, 0, 0);
     v17 = v14->uCompressedSize;
     if ( (signed int)v17 >= (signed int)*v15 )
@@ -380,7 +381,8 @@
   v2 = fopen("data\\dsounds.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dsounds.bin!");
+    Error("Unable to save dsounds.bin!");
+
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pSounds, 0x78u, v1->sNumSounds, v3);
   fclose(v3);
@@ -441,7 +443,8 @@
   v4 = fopen(Args, "r");
   File = v4;
   if ( !v4 )
-    Abortf("SoundListClass::load - Unable to open file: %s.");
+    Error("SoundListClass::load - Unable to open file: %s.");
+
   v5 = 0;
   Argsa = 0;
   if ( fgets(&Buf, 490, v4) )
@@ -461,7 +464,8 @@
   v6 = pAllocator->AllocNamedChunk(v2->pSounds, 120 * v5, "Snd Des.");
   v2->pSounds = (SoundDesc *)v6;
   if ( v6 == (void *)v3 )
-    Abortf("SoundListClass::load - Out of Memory!");
+    Error("SoundListClass::load - Out of Memory!");
+
   memset(v6, v3, 120 * v2->sNumSounds);
   v7 = File;
   v2->sNumSounds = v3;
--- a/CShow.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/CShow.h	Sat Sep 07 21:14:48 2013 +0200
@@ -1,5 +1,6 @@
 #pragma once
 #include "VideoPlayer.h"
+#include "ErrorHandling.h"
 
 
 /*  302 */
@@ -31,7 +32,7 @@
     case MOVIE_Outro:   VideoPlayer::MovieLoop("end_seq1", 20, 1, 1);      break;
 
     default:
-      assert(false && "Invalid movie requested in " __FUNCTION__);
+      Error("Invalid movie requested: %u", movie);
       break;
   }
 }
--- a/Chest.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Chest.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -3,7 +3,6 @@
 #endif
 
 #include <stdio.h>
-#include <assert.h>
 
 #include "BSPModel.h"
 #include "Items.h"
@@ -617,7 +616,8 @@
   v2 = fopen("data\\dchest.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dchest.bin!");
+    Error("Unable to save dchest.bin!");
+
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pChests, 0x24u, v1->uNumChests, v3);
   fclose(v3);
@@ -671,7 +671,8 @@
   v4 = fopen(Args, "r");
   File = v4;
   if ( !v4 )
-    Abortf("ChestDescriptionList::load - Unable to open file: %s.");
+    Error("ChestDescriptionList::load - Unable to open file: %s.");
+
   v5 = 0;
   Argsa = 0;
   if ( fgets(&Buf, 490, v4) )
@@ -692,7 +693,8 @@
   v7 = pAllocator->AllocNamedChunk(v6, 36 * v5, "Chest Descrip");
   v2->pChests = (ChestDesc *)v7;
   if ( v7 == (void *)v3 )
-    Abortf("ChestDescriptionList::load - Out of Memory!");
+    Error("ChestDescriptionList::load - Out of Memory!");
+
   memset(v7, v3, 36 * v2->uNumChests);
   v8 = File;
   v2->uNumChests = v3;
--- a/DecorationList.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/DecorationList.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -5,6 +5,7 @@
 #include "FrameTableInc.h"
 #include "mm7_data.h"
 #include "Indoor.h"
+#include "ErrorHandling.h"
 
 //----- (0045864C) --------------------------------------------------------
 void DecorationList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
@@ -14,8 +15,8 @@
        num_mm8_decs = data_mm8 ? *(int *)data_mm8 : 0;
 
   uNumDecorations = num_mm6_decs + num_mm7_decs + num_mm8_decs;
-  assert(uNumDecorations);
-  assert(!num_mm8_decs);
+  Assert(uNumDecorations);
+  Assert(!num_mm8_decs);
 
   pDecorations = (DecorationDesc *)pAllocator->AllocNamedChunk(pDecorations, uNumDecorations * sizeof(DecorationDesc), "Dec Descrip");
   memcpy(pDecorations, (char *)data_mm7 + 4, num_mm7_decs * sizeof(DecorationDesc));
@@ -86,7 +87,8 @@
   v3 = fopen(Args, "r");
   File = v3;
   if ( !v3 )
-    Abortf("DecorationDescriptionList::load - Unable to open file: %s.");
+    Error("DecorationDescriptionList::load - Unable to open file: %s.");
+
   v4 = 0;
   Argsa = 0;
   if ( fgets(&Buf, 490, v3) )
@@ -105,7 +107,8 @@
   v5 = pAllocator->AllocNamedChunk(v2->pDecorations, 84 * v4, "Dec Descrip");
   v2->pDecorations = (DecorationDesc *)v5;
   if ( !v5 )
-    Abortf("DecorationDescriptionList::load - Out of Memory!");
+    Error("DecorationDescriptionList::load - Out of Memory!");
+
   v6 = File;
   v2->uNumDecorations = 0;
   fseek(v6, 0, 0);
@@ -244,7 +247,8 @@
   v2 = fopen("data\\ddeclist.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save ddeclist.bin!");
+    Error("Unable to save ddeclist.bin!");
+
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pDecorations, 0x54u, v1->uNumDecorations, v3);
   fclose(v3);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ErrorHandling.h	Sat Sep 07 21:14:48 2013 +0200
@@ -0,0 +1,62 @@
+#pragma once
+
+#define Error(format, ...)             Error_impl_(__FILE__, __FUNCTION__, __LINE__, format, __VA_ARGS__)
+#define Assert(condition, format, ...) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, format, __VA_ARGS__)
+#define Assert(condition)              Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, nullptr)
+
+
+
+
+#include <stdarg.h>
+inline __declspec(noreturn) void Error_impl_(const char *filename, const char *functionname, int line,
+                                             const char *format, ...)
+{
+  va_list va;
+  va_start(va, format);
+  {
+    char header[4096];
+    sprintf(header, "Error in %s: %u\n\t%s\n\n", filename, line, functionname);
+
+    char msg_body[8192];
+    vsprintf(msg_body, format, va);
+
+    wchar_t msg[sizeof(header) + sizeof(msg_body)];
+    swprintf(msg, L"%S %S", header, msg_body);
+
+    extern void MsgBox(const wchar_t *, const wchar_t *);
+    MsgBox(msg, L"Error");
+  }
+  va_end(va);
+
+  __debugbreak();
+}
+
+
+inline void Assert_impl_(const char *filename, const char *functionname, int line,
+                         bool condition, const char *condition_string, const char *format, ...)
+{
+  if (condition)
+    return;
+
+  va_list va;
+  va_start(va, format);
+  {
+    char header[4096];
+    sprintf(header, "Assertion in %s: %u\n\t%s:\n%s\n\n", filename, line, functionname, condition_string);
+
+    char msg_body[8192];
+    vsprintf(msg_body, format, va);
+    
+    wchar_t msg[sizeof(header) + sizeof(msg_body)];
+    if (format)
+      swprintf(msg, L"%S %S", header, msg_body);
+    else
+      swprintf(msg, L"%S", header);
+
+    extern void MsgBox(const wchar_t *, const wchar_t *);
+    MsgBox(msg, L"Assertion");
+  }
+  va_end(va);
+
+  __debugbreak();
+}
\ No newline at end of file
--- a/Events.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Events.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,7 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
 #include <stdlib.h>
 
 #include "Weather.h"
@@ -67,24 +66,23 @@
 {
   FILE *pLodFile; // eax@1
   unsigned int uTextureSize; // esi@3
-  char Args[60]; // [sp+8h] [bp-B4h]@6
+  //char Args[60]; // [sp+8h] [bp-B4h]@6
   void *ptr; // [sp+B8h] [bp-4h]@1
   Texture DstBuf; // [sp+6Ch] [bp-50h]@1
 
   ptr = pEvents_LOD->LoadRaw(pContainerName, 0);
   pLodFile = pEvents_LOD->FindContainer(pContainerName, 0);
   if ( !pLodFile )
-    Abortf("Unable to load %s", pContainerName);
+    Error("Unable to load %s", pContainerName);
+
   fread(&DstBuf, 1, 48, pLodFile);
   uTextureSize = DstBuf.uDecompressedSize;
   if ( !DstBuf.uDecompressedSize )
     uTextureSize = DstBuf.uTextureSize;
   memset(&DstBuf, 0, 72);
   if ( uTextureSize >= (signed int)uBufferSize )
-    {
-    sprintf(Args, "File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize);
-    Abortf(Args);
-    }
+    Error("File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize);
+
   memcpy(pBuffer, ptr, uTextureSize);
   pAllocator->FreeChunk(ptr);
   return uTextureSize;
--- a/GUIFont.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/GUIFont.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -3,7 +3,6 @@
 #endif
 
 #include <string>
-#include <assert.h>
 
 #include "LOD.h"
 #include "GUIFont.h"
@@ -49,10 +48,8 @@
         {
         pallete_index =pIcons_LOD->LoadTexture(pFontPalette, TEXTURE_16BIT_PALETTE);
         if (pallete_index == -1)
-            {
-            wsprintfA(pTmpBuf.data(), "Unable to open %s", pFontPalette);
-            Abortf(pTmpBuf.data());
-            }	
+            Error("Unable to open %s", pFontPalette);
+
         pFont->pFontPalettes[palletes_count] = pIcons_LOD->pTextures[pallete_index].pPalette16;
         ++palletes_count;
         }
@@ -285,7 +282,7 @@
       }
   currentFont=pFontMain; // esi@3
   uInStrLen = strlen(pString);
-  assert(uInStrLen < sizeof(pTmpBuf3));
+  Assert(uInStrLen < sizeof(pTmpBuf3));
   strcpy(pTmpBuf3.data(), pString);
   if (uInStrLen==0)
       return pTmpBuf3.data();
--- a/GUIProgressBar.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/GUIProgressBar.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "GUIProgressBar.h"
 #include "LOD.h"
 #include "Mouse.h"
@@ -43,7 +41,7 @@
       break;
 
     default:
-      assert(false && "Invalid GUIProgressBar type");
+      Error("Invalid GUIProgressBar type: %u", type);
   }
 
   //v2 = this;
@@ -110,7 +108,7 @@
     case PartyAlignment_Good:    pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break;
     case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break;
     case PartyAlignment_Evil:    pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break;
-    default: assert(false);
+    default: Error("Invalid alignment type: %u", pParty->alignment);
   }
 
   uProgressCurrent = 0;
--- a/Game.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Game.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "Vis.h"
 
 #include "LightmapBuilder.h"
@@ -127,7 +125,7 @@
         pIndoor->Draw();
       else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
         pOutdoor->Draw();
-      else assert(false);
+      else Error("Invalid level type: %u", uCurrentlyLoadedLevelType);
 
       if (pRenderer->pRenderD3D)
       {
@@ -543,7 +541,7 @@
       if (num_conscious_players)
       {
         int idx = conscious_players_ids[rand() % num_conscious_players];
-        assert(idx >= 0);
+        Assert(idx >= 0);
         pPlayers[idx + 1]->PlaySound(SPEECH_99, 0);
       }
 
@@ -1178,7 +1176,7 @@
           else
             face->uAttributes |= FACE_OUTLINED;
         }
-        else assert(false);
+        else Error("Invalid level type", uCurrentlyLoadedLevelType);
       }
       break;
 
--- a/IconFrameTable.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/IconFrameTable.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -105,7 +105,7 @@
   v2 = fopen("data\\dift.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dift.bin!");
+    Error("Unable to save dift.bin!");
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pIcons, 0x20u, v1->uNumIcons, v3);
   fclose(v3);
@@ -119,8 +119,8 @@
        num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0;
 
   uNumIcons = num_mm6_frames + num_mm7_frames + num_mm8_frames;
-  assert(uNumIcons);
-  assert(!num_mm8_frames);
+  Assert(uNumIcons);
+  Assert(!num_mm8_frames);
 
   pIcons = (IconFrame *)pAllocator->AllocNamedChunk(pIcons, uNumIcons * sizeof(IconFrame), "I Frames");
   memcpy(pIcons,                                   (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame));
@@ -160,7 +160,7 @@
   v3 = fopen(Args, "r");
   File = v3;
   if ( !v3 )
-    Abortf("IconFrameTable::load - Unable to open file: %s.", Args);
+    Error("IconFrameTable::load - Unable to open file: %s.", Args);
   v4 = 0;
   v21 = 0;
   v22 = 1;
@@ -173,7 +173,7 @@
       if ( v20.uPropCount && *v20.pProperties[0] != 47 )
       {
         if ( v20.uPropCount < 3 )
-          Abortf("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22);
+          Error("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22);
         ++v21;
       }
       ++v22;
--- a/Indoor.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Indoor.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "LightmapBuilder.h"
 #include "DecalBuilder.h"
 #include "stru9.h"
@@ -64,7 +62,7 @@
 stru337 stru_F81018;
 BspRenderer_PortalViewportData stru_F8A590;
 BspRenderer *pBspRenderer = new BspRenderer; // idb
-stru141 stru_721530;
+stru141_actor_collision_object stru_721530;
 std::array<stru352, 480> stru_F83B80;
 
 
@@ -1749,7 +1747,7 @@
   }
 
   if ( !pGames_LOD->DoesContainerExist(pFilename) )
-    Abortf("Unable to find %s in Games.LOD", pFilename);
+    Error("Unable to find %s in Games.LOD", pFilename);
 
   //v238 = pFilename - 4;
   //v81 = strlen(pFilename);
@@ -2971,7 +2969,7 @@
             v25 = abs(v15->pFacePlane_old.vNormal.z);
             //v26 = v87;
             if ( v24 > v25 )
-              Abortf("Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
+              Error("Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
                 door->uDoorID,
                 door->pFaceIDs[v88],
                 v15->pFacePlane_old.dist,
@@ -3185,7 +3183,7 @@
   int v18; // ecx@33
   BLVFace *v19; // eax@34
   int v20; // ecx@46
-  int v21; // eax@46
+  //int v21; // eax@46
   int v22; // edi@46
   int v23; // eax@48
   unsigned int v24; // eax@51
@@ -3210,9 +3208,9 @@
   __int16 v43; // dx@96
   int v44; // ecx@96
   int v45; // edi@101
-  int v46; // edi@101
-  int v47; // eax@101
-  unsigned __int64 v48; // qax@101
+  //int v46; // edi@101
+  //int v47; // eax@101
+  //unsigned __int64 v48; // qax@101
   unsigned __int8 v49; // zf@103
   unsigned __int8 v50; // sf@103
   unsigned __int8 v51; // of@103
@@ -3361,29 +3359,28 @@
         return;
     }
     v20 = v0->uActorRadius;
-    v21 = v0->uActorHeight;
     stru_721530.field_84 = -1;
     stru_721530.field_70 = 0;
     uSectorID = 0;
     stru_721530.field_0 = 1;
-    stru_721530.field_8 = v20;
+    stru_721530.field_8_radius = v20;
     stru_721530.prolly_normal_d = v20;
-    stru_721530.field_C = v21;
+    stru_721530.height = v0->uActorHeight;
     v22 = 0;
     while ( 1 )
     {
-      stru_721530.field_34.x = v0->vPosition.x;
-      stru_721530.normal.x = stru_721530.field_34.x;
-      stru_721530.field_34.y = v0->vPosition.y;
-      stru_721530.normal.y = stru_721530.field_34.y;
+      stru_721530.position.x = v0->vPosition.x;
+      stru_721530.normal.x = stru_721530.position.x;
+      stru_721530.position.y = v0->vPosition.y;
+      stru_721530.normal.y = stru_721530.position.y;
       v23 = v0->vPosition.z;
       stru_721530.normal.z = v23 + v20 + 1;
-      stru_721530.field_34.z = v23 - v20 + stru_721530.field_C - 1;
-      if ( stru_721530.field_34.z < stru_721530.normal.z )
-        stru_721530.field_34.z = v23 + v20 + 1;
-      stru_721530.field_1C = v0->vVelocity.x;
-      stru_721530.field_20 = v0->vVelocity.y;
-      stru_721530.field_24 = v0->vVelocity.z;
+      stru_721530.position.z = v23 - v20 + stru_721530.height - 1;
+      if ( stru_721530.position.z < stru_721530.normal.z )
+        stru_721530.position.z = v23 + v20 + 1;
+      stru_721530.velocity.x = v0->vVelocity.x;
+      stru_721530.velocity.y = v0->vVelocity.y;
+      stru_721530.velocity.z = v0->vVelocity.z;
       stru_721530.uSectorID = v0->uSectorID;
       if ( !stru_721530._47050A(v22) )
       {
@@ -3434,12 +3431,9 @@
         }
         else
         {
-          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-          v30 = v58 + v0->vPosition.x;
-          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-          v31 = v58 + v0->vPosition.y;
-          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
-          v32 = v58 + v0->vPosition.z;
+          v30 = v0->vPosition.x + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x);
+          v31 = v0->vPosition.y + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y);
+          v32 = v0->vPosition.z + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z);
         }
         v33 = collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID);
         v34 = pIndoor->pFaces[uFaceID].uAttributes;
@@ -3463,13 +3457,13 @@
               v0->uSectorID = LOWORD(stru_721530.uSectorID);
               goto LABEL_123;
             }
-            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-            v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16;
-            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-            v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16;
-            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
+            //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
+            v0->vPosition.x += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x);
+            //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16;
+            v0->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y);
+            //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16;
             v36 = stru_721530.uFaceID;
-            v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
+            v0->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z);
             v0->uSectorID = LOWORD(stru_721530.uSectorID);
             stru_721530.field_70 += stru_721530.field_7C;
             v37 = PID_ID(v36);
@@ -3483,15 +3477,8 @@
                   v45 = stru_5C6E00->Atan2(
                           v0->vPosition.x - pLevelDecorations[v37].vPosition.x,
                           v0->vPosition.y - pLevelDecorations[v37].vPosition.y);
-                  v54 = stru_5C6E00->Cos(v45);
-                  v56 = (unsigned __int64)(v54 * (signed __int64)(signed int)_this) >> 16;
-                  v46 = v45 - stru_5C6E00->uIntegerHalfPi;
-                  v0->vVelocity.x = v54 * _this >> 16;
-                  v47 = stru_5C6E00->Sin(v45);
-                  v54 = v47;
-                  v48 = v47 * (signed __int64)(signed int)_this;
-                  v56 = v48 >> 16;
-                  v0->vVelocity.y = WORD1(v48);
+                  v0->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v45), _this);
+                  v0->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v45), _this);
                   goto LABEL_119;
                 }
                 if ( PID_TYPE(v36) == OBJECT_BModel)
@@ -3517,17 +3504,12 @@
                                                                               * v0->vVelocity.y
                                                                               + v38->pFacePlane_old.vNormal.z
                                                                               * v0->vVelocity.z) >> 16;
-                    if ( stru_721530.field_64 >> 3 > v61 )
-                      v61 = stru_721530.field_64 >> 3;
-                    v58 = v38->pFacePlane_old.vNormal.x;
-                    v58 = (unsigned __int64)(v61 * (signed __int64)v58) >> 16;
-                    _this = v38->pFacePlane_old.vNormal.y;
-                    _this = (unsigned __int64)(v61 * (signed __int64)(signed int)_this) >> 16;
-                    v56 = v38->pFacePlane_old.vNormal.z;
-                    v56 = (unsigned __int64)(v61 * (signed __int64)v56) >> 16;
-                    v0->vVelocity.x += v58;
-                    v0->vVelocity.y += _this;
-                    v0->vVelocity.z += v56;
+                    if ( (stru_721530.speed >> 3) > v61 )
+                      v61 = stru_721530.speed >> 3;
+
+                    v0->vVelocity.x += fixpoint_sub0(v61, v38->pFacePlane_old.vNormal.x);
+                    v0->vVelocity.y += fixpoint_sub0(v61, v38->pFacePlane_old.vNormal.y);
+                    v0->vVelocity.z += fixpoint_sub0(v61, v38->pFacePlane_old.vNormal.z);
                     v41 = v38->uPolygonType;
                     if ( v41 != 4 && v41 != 3 )
                     {
@@ -3551,18 +3533,10 @@
                     EventProcessor(pIndoor->pFaceExtras[v38->uFaceExtraID].uEventID, 0, 1);
                 }
 LABEL_119:
-                v56 = v0->vVelocity.x;
-                v54 = 58500;
-                v56 = (unsigned __int64)(58500i64 * v56) >> 16;
-                v0->vVelocity.x = v56;
-                v56 = v0->vVelocity.y;
-                v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16;
-                v54 = 58500;
-                v0->vVelocity.y = v56;
-                v56 = v0->vVelocity.z;
-                v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16;
+                v0->vVelocity.x = fixpoint_sub0(58500, v0->vVelocity.x);
+                v0->vVelocity.y = fixpoint_sub0(58500, v0->vVelocity.y);
+                v0->vVelocity.z = fixpoint_sub0(58500, v0->vVelocity.z);
                 v22 = 0;
-                v0->vVelocity.z = v56;
                 goto LABEL_120;
               }
               if ( v0->GetActorsRelation(0) )
@@ -3670,7 +3644,7 @@
   __int16 v29; // ax@85
   signed int v30; // edi@94
   int v31; // esi@94
-  char Args; // [sp+350h] [bp-C4h]@16
+  //char Args; // [sp+350h] [bp-C4h]@16
   int v34[4]; // [sp+3E8h] [bp-2Ch]@96
   int v35; // [sp+3F8h] [bp-1Ch]@1
   //char b[4]; // [sp+3FCh] [bp-18h]@58
@@ -3727,21 +3701,17 @@
          (char *)&pDest)
      - 1;
   if ( !v4 )
-  {
-    sprintf(&Args, "Unable to open %s", pCurrentMapName);
-    Abortf(&Args);
-  }
+    Error("Unable to open %s", pCurrentMapName);
+
   v5 = v4 - 1;
   if ( !v5 )
-  {
-    sprintf(&Args, "File %s is not a BLV File", pCurrentMapName);
-    Abortf(&Args);
-  }
+    Error("File %s is not a BLV File", pCurrentMapName);
+
   v6 = v5 - 1;
   if ( !v6 )
-    Abortf("Attempt to open new level before clearing old");
+    Error("Attempt to open new level before clearing old");
   if ( v6 == 1 )
-    Abortf("Out of memory loading indoor level");
+    Error("Out of memory loading indoor level");
   if ( !(dword_6BE364_game_settings_1 & 0x2000) )
   {
     InitializeActors();
@@ -3836,21 +3806,6 @@
     if (!pFace->uBitmapID != -1)
       pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id1);
  }
-
-  /*i = 0;
-  if ( (signed int)pIndoor->uNumFaces > 0 )
-  {
-    v12 = 0;
-    do
-    {
-      if ( pIndoor->pFaces[v12].uBitmapID != -1 )
-        pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id1);
-      ++i;
-      ++v12;
-    }
-    while ( i < (signed int)pIndoor->uNumFaces );
-  }*/
-
   
   pGameLoadingUI_ProgressBar->Progress();
   
@@ -4828,11 +4783,12 @@
               }
               else
               {
-                LODWORD(v19) = pBLVRenderParams->field_40 << 16;
+                __debugbreak(); // sw rendering
+                /*LODWORD(v19) = pBLVRenderParams->field_40 << 16;
                 HIDWORD(v19) = pBLVRenderParams->field_40 >> 16;
                 v20 = v19 / x;
                 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v19 / x) >> 16;
-                v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16;
+                v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16;*/
               }
               //HIWORD(v21) = HIWORD(x);
               //LOWORD(v21) = 0;
@@ -4942,7 +4898,7 @@
   }
 }
 //----- (0043FA33) --------------------------------------------------------
-void __fastcall PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID)
+void PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID)
 {
   LevelDecoration *v2; // esi@1
   DecorationDesc *v3; // ebx@2
@@ -5152,113 +5108,97 @@
   }
 }
 //----- (0048653D) --------------------------------------------------------
-int stru149::_48653D(int a2, int a3, int a4, int a5, int a6, int a7)//portal frustum culling
+void stru149::_48653D_frustum_blv(int a2, int a3, int a4, int a5, int a6, int a7)//portal frustum culling
 {
-  stru149 *v7; // esi@1
+  //stru149 *v7; // esi@1
   int v8; // edi@1
   int v9; // eax@1
   //int v10; // edx@1
   //int v11; // ecx@1
-  int v12; // eax@1
-  int v13; // ebx@2
-  int v14; // ecx@2
-  int v15; // eax@2
+  //int v12; // eax@1
+  //int v13; // ebx@2
+  //int v14; // ecx@2
+  //int v15; // eax@2
   int v16; // ST14_4@3
   int v17; // ST10_4@3
-  int v18; // eax@5
+  //int v18; // eax@5
   int v19; // ST10_4@6
-  int v20; // eax@8
+  //int v20; // eax@8
   int v21; // ST10_4@9
-  int v22; // eax@10
-  int v23; // ecx@10
-  int v24; // eax@10
-  int result; // eax@10
+  //int v22; // eax@10
+  //int v23; // ecx@10
+  //int v24; // eax@10
+  //int result; // eax@10
   //int v26; // [sp+14h] [bp-14h]@1
-  int v27; // [sp+18h] [bp-10h]@1
+  //int v27; // [sp+18h] [bp-10h]@1
   int v28; // [sp+1Ch] [bp-Ch]@1
   int v29; // [sp+24h] [bp-4h]@1
-  int v30; // [sp+30h] [bp+8h]@10
-  int v31; // [sp+3Ch] [bp+14h]@10
-
-  v7 = this;
+  //int v30; // [sp+30h] [bp+8h]@10
+  //int v31; // [sp+3Ch] [bp+14h]@10
+
   v8 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotY);
   v29 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotY);
   v28 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotX);
   v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX);
   //v11 = -pBLVRenderParams->vPartyPos.y;
   //v26 = -pBLVRenderParams->vPartyPos.x;
-  v27 = v9;
-  v12 = -pBLVRenderParams->vPartyPos.z;
+  //v27 = v9;
+  //v12 = -pBLVRenderParams->vPartyPos.z;
   if ( pBLVRenderParams->sPartyRotX )
   {
     v16 = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
-    v13 = v28;
     v17 = -65536 * pBLVRenderParams->vPartyPos.z;
-    v7->field_0_party_dir_x = ((unsigned __int64)(v16 * (signed __int64)v28) >> 16)
-                + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)v27) >> 16);
-    v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x;
-    v14 = v27;
-    v15 = ((unsigned __int64)(v17 * (signed __int64)v28) >> 16) - ((unsigned __int64)(v16 * (signed __int64)v27) >> 16);
+    this->field_0_party_dir_x = fixpoint_sub0(v16, v28) + fixpoint_sub0((-pBLVRenderParams->vPartyPos.z) << 16, v9);
+    this->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x;
+    this->field_8_party_dir_z = fixpoint_sub0(v17, v28) - fixpoint_sub0(v16, v9);
   }
   else
   {
-    v7->field_0_party_dir_x = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
-    v13 = v28;
-    v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x;
-    v14 = v27;
-    v15 = v12 << 16;
+    this->field_0_party_dir_x = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
+    this->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x;
+    this->field_8_party_dir_z = (-pBLVRenderParams->vPartyPos.z) << 16;
   }
-  v7->field_8 = v15;
-  if ( pBLVRenderParams->sPartyRotX )
+
+  if (pBLVRenderParams->sPartyRotX)
   {
-    v19 = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16);
-    v7->field_C = ((unsigned __int64)(v19 * (signed __int64)v13) >> 16)
-                + ((unsigned __int64)(a4 * (signed __int64)v14) >> 16);
-    v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16)
-                 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16);
-    v18 = ((unsigned __int64)(a4 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v14) >> 16);
+    v19 = fixpoint_sub0(a2, v8) + fixpoint_sub0(a3, v29);
+
+    this->field_C = fixpoint_sub0(v19, v28) + fixpoint_sub0(a4, v9);
+    this->field_10 = fixpoint_sub0(a3, v8) - fixpoint_sub0(a2, v29);
+    this->field_14 = fixpoint_sub0(a4, v28) - fixpoint_sub0(v19, v9);
   }
   else
   {
-    v7->field_C = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16)
-                + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16);
-    v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16)
-                 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16);
-    v18 = a4;
+    this->field_C = fixpoint_sub0(a2, v8) + fixpoint_sub0(a3, v29);
+    this->field_10 = fixpoint_sub0(a3, v8) - fixpoint_sub0(a2, v29);
+    this->field_14 = a4;
   }
-  v7->field_14 = v18;
-  if ( pBLVRenderParams->sPartyRotX )
+
+  if (pBLVRenderParams->sPartyRotX)
   {
-    v21 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16);
-    v7->field_18 = ((unsigned __int64)(v21 * (signed __int64)v13) >> 16)
-                 + ((unsigned __int64)(a7 * (signed __int64)v14) >> 16);
-    v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16)
-                 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16);
-    v20 = ((unsigned __int64)(a7 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v21 * (signed __int64)v14) >> 16);
+    v21 = fixpoint_sub0(a5, v8) + fixpoint_sub0(a6, v29);
+
+    this->field_18 = fixpoint_sub0(v21, v28) + fixpoint_sub0(a7, v9);
+    this->field_1C = fixpoint_sub0(a6, v8) - fixpoint_sub0(a5, v29);
+    this->field_20 = fixpoint_sub0(a7, v28) - fixpoint_sub0(v21, v9);
   }
   else
   {
-    v7->field_18 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16)
-                 + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16);
-    v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16)
-                 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16);
-    v20 = a7;
+    this->field_18 = fixpoint_sub0(a5, v8) + fixpoint_sub0(a6, v29);
+    this->field_1C = fixpoint_sub0(a6, v8) - fixpoint_sub0(a5, v29);
+    this->field_20 = a7;
   }
-  v7->field_18 = -v7->field_18;
-  v7->field_1C = -v7->field_1C;
-  v7->field_20 = v20;
-  v22 = v7->field_C;
-  v7->field_20 = -v7->field_20;
-  v23 = ((unsigned __int64)(v22 * (signed __int64)v7->field_0_party_dir_x) >> 16)
-      + ((unsigned __int64)(v7->field_10 * (signed __int64)v7->field_4_party_dir_y) >> 16)
-      + ((unsigned __int64)(v7->field_14 * (signed __int64)v7->field_8) >> 16);
-  v30 = v7->field_18;
-  v24 = v7->field_0_party_dir_x;
-  v7->field_24 = v23;
-  v31 = (unsigned __int64)(v30 * (signed __int64)v24) >> 16;
-  result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4_party_dir_y) >> 16;
-  v7->field_28 = v31 + result + ((unsigned __int64)(v7->field_20 * (signed __int64)v7->field_8) >> 16);
-  return result;
+
+  this->field_18 = -this->field_18;
+  this->field_1C = -this->field_1C;
+  this->field_20 = -this->field_20;
+
+  this->field_24 = fixpoint_dot(this->field_C,  this->field_0_party_dir_x,
+                                this->field_10, this->field_4_party_dir_y,
+                                this->field_14, this->field_8_party_dir_z);
+  this->field_28 = fixpoint_dot(this->field_18, this->field_0_party_dir_x,
+                                this->field_1C, this->field_4_party_dir_y,
+                                this->field_20, this->field_8_party_dir_z);
 }
 //----- (00407A1C) --------------------------------------------------------
 bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v)
@@ -5373,7 +5313,7 @@
   int v112; // [sp+18h] [bp-64h]@128
   signed int v113; // [sp+20h] [bp-5Ch]@1
   signed int v114; // [sp+24h] [bp-58h]@1
-  unsigned __int64 a4; // [sp+28h] [bp-54h]@1
+  //unsigned __int64 a4; // [sp+28h] [bp-54h]@1
   unsigned int a4_8; // [sp+30h] [bp-4Ch]@1
   int v117; // [sp+34h] [bp-48h]@4
   int v118; // [sp+34h] [bp-48h]@39
@@ -5442,13 +5382,13 @@
 
   __debugbreak();
 
-  a4 = __PAIR__(z, x);
   v4 = stru_5C6E00->Atan2(v.x - x, v.y - z);
   v114 = 0;
   v97.z = y;
+  v97.x = x;
+  v97.y = z;
   v113 = 0;
   a4_8 = v4;
-  *(_QWORD *)&v97.x = a4;
   if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
   {
     Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
@@ -5602,10 +5542,12 @@
       v54 = pOut.x;
     }
     v72.z = y;
-    *(_QWORD *)&v72.x = a4;
+    v72.x = x;
+    v72.y = z;
     Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz);
     v73.z = v.z;
-    *(_QWORD *)&v73.x = *(_QWORD *)&v;
+    v73.x = v.x;
+    v73.y = v.y;
     Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163);
     v74 = outy - pOut.y;
     v75 = v163 - outz;
@@ -5892,10 +5834,12 @@
   }
 LABEL_37:
   v27.z = y;
-  *(_QWORD *)&v27.x = a4;
+  v27.x = x;
+  v27.y = z;
   Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz);
   v28.z = v.z;
-  *(_QWORD *)&v28.x = *(_QWORD *)&v;
+  v28.x = v.x;
+  v28.y = v.y;
   Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163);
   v29 = outy - pOut.y;
   v30 = v163 - outz;
--- a/IndoorCameraD3D.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/IndoorCameraD3D.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -710,7 +710,7 @@
 
 void IndoorCameraD3D::DebugDrawPortal(BLVFace *pFace)
 {
-  assert(pFace->uNumVertices <= 32);
+  Assert(pFace->uNumVertices <= 32);
 
   RenderVertexSoft sw[32];
   for (uint i = 0; i < pFace->uNumVertices; ++i)
--- a/Indoor_stuff.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/Indoor_stuff.h	Sat Sep 07 21:14:48 2013 +0200
@@ -247,29 +247,27 @@
 
 /*  134 */
 #pragma pack(push, 1)
-struct stru141
+struct stru141_actor_collision_object
 {
   int _47050A(int a2);
 
   int field_0;
   int prolly_normal_d;
-  int field_8;
-  int field_C;
+  int field_8_radius;
+  int height;
   int field_10;
   int field_14;
   int field_18;
-  int field_1C;
-  int field_20;
-  int field_24;
+  Vec3_int_ velocity;
   Vec3_int_ normal;
-  Vec3_int_ field_34;
+  Vec3_int_ position;
   Vec3_int_ normal2;
   int field_4C;
   int field_50;
   int field_54;
-  Vec3_int_ field_58;
-  int field_64;
-  int field_68;
+  Vec3_int_ direction; // velocity's unit vector
+  int speed;
+  int inv_speed;
   int field_6C;
   int field_70;
   unsigned int uSectorID;
@@ -287,7 +285,7 @@
   int field_A4;
 };
 #pragma pack(pop)
-extern stru141 stru_721530;
+extern stru141_actor_collision_object stru_721530;
 
 
 
--- a/Items.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Items.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -3,7 +3,6 @@
 #endif
 
 #include <stdlib.h>
-#include <assert.h>
 
 #include "Items.h"
 #include "MapInfo.h"
--- a/LOD.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/LOD.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -21,12 +21,15 @@
 
 LODFile_IconsBitmaps *pIcons_LOD = nullptr;
 LODFile_IconsBitmaps *pIcons_LOD_mm6 = nullptr;
+LODFile_IconsBitmaps *pIcons_LOD_mm8 = nullptr;
 
 LODFile_IconsBitmaps *pBitmaps_LOD = nullptr;
 LODFile_IconsBitmaps *pBitmaps_LOD_mm6 = nullptr;
+LODFile_IconsBitmaps *pBitmaps_LOD_mm8 = nullptr;
 
 LODFile_Sprites *pSprites_LOD = nullptr;
 LODFile_Sprites *pSprites_LOD_mm6 = nullptr;
+LODFile_Sprites *pSprites_LOD_mm8 = nullptr;
 
 LODWriteableFile *pNew_LOD = nullptr;
 LODWriteableFile *pGames_LOD = nullptr;
@@ -1453,7 +1456,7 @@
 //----- (00461F71) --------------------------------------------------------
 bool LOD::File::AppendDirectory(LOD::Directory *pDir, const void *pData)
 {
-  assert(uNumSubDirs < 299);
+  Assert(uNumSubDirs < 299);
 
   memcpy(&pSubIndices[uNumSubDirs++], pDir, sizeof(LOD::Directory));
   fwrite(pData, 1, pDir->uDataSize, pOutputFileHandle);
@@ -1677,7 +1680,7 @@
   uCurrentIndexDir = 0;
   uLODDataSize = lod_indx.uDataSize;
   uNumSubDirs = lod_indx.uNumSubIndices;
-  assert(uNumSubDirs <= 300);
+  Assert(uNumSubDirs <= 300);
 
   uOffsetToSubIndex = lod_indx.uOfsetFromSubindicesStart;
   fseek(pFile, uOffsetToSubIndex, SEEK_SET);
@@ -2079,7 +2082,8 @@
   v5 = v4;
   File = v4;
   if ( !v4 )
-    Abortf("Unable to load %s", pContainer);
+    Error("Unable to load %s", pContainer);
+
   fread(&DstBuf, 1u, 0x30u, v4);
   Argsa = DstBuf.uTextureSize;
   if ( DstBuf.uDecompressedSize )
@@ -2131,7 +2135,7 @@
   int v20; // edx@15
   signed int v21; // ecx@18
   signed int v22; // ecx@23
-  char Args[100]; // [sp+4h] [bp-68h]@3
+  //char Args[100]; // [sp+4h] [bp-68h]@3
   FILE *File; // [sp+68h] [bp-4h]@1
 
   v4 = this;
@@ -2140,10 +2144,8 @@
   {
     File = FindContainer("pending", 0);
     if ( !File )
-    {
-      sprintf(Args, "Can't find %s!", pContainer);
-      Abortf(Args);
-    }
+      Error("Can't find %s!", pContainer);
+
   }
   v5 = pDst;
   fread(pDst, 1u, 0x30u, File);
@@ -2832,7 +2834,7 @@
 {
   uint id = LoadTexture(pContainer, uTextureType);
 
-  assert(id != -1 && L"Texture not found");
+  Assert(id != -1 && L"Texture not found");
 
   return &pTextures[id];
 }
@@ -2857,7 +2859,7 @@
 //  if (!uNumLoadedFiles)
 //  {
 //LABEL_5:
-    assert(uNumLoadedFiles < 1000);
+    Assert(uNumLoadedFiles < 1000);
     /*if (uNumLoadedFiles >= 1000)
     {
       Log::Warning(L"Maximum texture number exceeded");
--- a/LOD.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/LOD.h	Sat Sep 07 21:14:48 2013 +0200
@@ -1,9 +1,9 @@
 #pragma once
 #include <stdio.h>
 #include <memory.h>
-#include <assert.h>
 
 #include "Texture.h"
+#include "ErrorHandling.h"
 
 class Sprite;
 
@@ -166,7 +166,7 @@
 
   inline struct Texture *GetTexture(int idx)
   {
-    assert(idx < 1000);
+    Assert(idx < 1000, "Texture index out of bounds (%u)", idx);
     if (idx == -1) 
       return nullptr; // we need to return dummy texture here
     return &pTextures[idx];
@@ -302,14 +302,18 @@
 
 
 extern LODFile_IconsBitmaps *pEvents_LOD;
+
 extern LODFile_IconsBitmaps *pIcons_LOD;
 extern LODFile_IconsBitmaps *pIcons_LOD_mm6;
+extern LODFile_IconsBitmaps *pIcons_LOD_mm8;
 
 extern LODFile_IconsBitmaps *pBitmaps_LOD;
 extern LODFile_IconsBitmaps *pBitmaps_LOD_mm6;
+extern LODFile_IconsBitmaps *pBitmaps_LOD_mm8;
 
 extern LODFile_Sprites *pSprites_LOD;
 extern LODFile_Sprites *pSprites_LOD_mm6;
+extern LODFile_Sprites *pSprites_LOD_mm8;
 
 extern LODWriteableFile *pNew_LOD;
 extern LODWriteableFile *pGames_LOD;
--- a/Level/Decoration.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Level/Decoration.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1,5 +1,6 @@
 #include "Decoration.h"
 #include "../Party.h"
+#include "../ErrorHandling.h"
 
 //----- (004583B0) --------------------------------------------------------
 LevelDecoration::LevelDecoration()
@@ -106,7 +107,7 @@
     case 225: case 226: case 227:
       return 0;
 
-    default: assert(false && "Invalid Decoration");
+    default: Error("Invalid DecorationDescID: %u", uDecorationDescID);
   }
 }
 
--- a/LightmapBuilder.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/LightmapBuilder.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1,11 +1,10 @@
-#include <assert.h>
-
 #include "LightmapBuilder.h"
 #include "Game.h"
 #include "stru314.h"
 #include "Outdoor.h"
 #include "Outdoor_stuff.h"
 #include "Log.h"
+#include "ErrorHandling.h"
 
 #include "OutdoorCamera.h"
 #include "Lights.h"
@@ -1655,7 +1654,7 @@
         {
           v28 = &std__vector_000004[*i];
           if ( !DrawLightmap(v28, &arg4, 0.0) )
-            assert(false && "Invalid lightmap detected!");
+            Error("Invalid lightmap detected! (%u)", *i);
         }
       }
       else
--- a/MM7.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/MM7.h	Sat Sep 07 21:14:48 2013 +0200
@@ -12,19 +12,7 @@
 typedef unsigned __int64 _QWORD;
 
 
-/*  288 */
-/*#pragma pack(push, 1)
-struct CheckHRESULT_stru0
-{
-  void CheckHRESULT(HRESULT a2, const char *Str, int a4, unsigned int uType);
-  void *_466D09_xcpt_string(std::string a2, const char *Str, int a4);
-  void ShowMessageBox(std::string *a0, std::string lpCaption, UINT uType, std::string lpText, int line);
-  char ddraw_error(HRESULT hr, char *Str, size_t a3);
-  char dinput_error(int a1, const char *Str, int a3);
 
-  void ( ***vdestructor_ptr)(CheckHRESULT_stru0 *, bool);
-};
-#pragma pack(pop)*/
 
 
 
--- a/Math.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/Math.h	Sat Sep 07 21:14:48 2013 +0200
@@ -25,6 +25,7 @@
 #pragma pack(pop)
 
 int fixpoint_sub0(int, int);
+int fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2);
 int fixpoint_div(int, int);
 int fixpoint_mul(int, int);
 int fixpoint_from_float(float value);
--- a/Monsters.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Monsters.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -368,7 +368,8 @@
   v3 = fopen(Args, "r");
   File = v3;
   if ( !v3 )
-    Abortf("MonsterRaceListStruct::load - Unable to open file: %s.");
+    Error("MonsterRaceListStruct::load - Unable to open file: %s.");
+
   v4 = 0;
   Argsa = 0;
   if ( fgets(&Buf, 490, v3) )
@@ -387,7 +388,8 @@
   v5 = pAllocator->AllocNamedChunk(v2->pMonsters, 152 * v4, "Mon Race");
   v2->pMonsters = (MonsterDesc *)v5;
   if ( !v5 )
-    Abortf("MonsterRaceListStruct::load - Out of Memory!");
+    Error("MonsterRaceListStruct::load - Out of Memory!");
+
   v6 = File;
   v2->uNumMonsters = 0;
   fseek(v6, 0, 0);
@@ -463,8 +465,8 @@
        num_mm8_monsters = data_mm8 ? *(int *)data_mm8 : 0;
 
   uNumMonsters = num_mm6_monsters + num_mm7_monsters + num_mm8_monsters;
-  assert(uNumMonsters);
-  assert(!num_mm8_monsters);
+  Assert(uNumMonsters);
+  Assert(!num_mm8_monsters);
 
   pMonsters = (MonsterDesc *)pAllocator->AllocNamedChunk(pMonsters, sizeof(MonsterDesc) * uNumMonsters, "Mon Race");
   memcpy(pMonsters, (char *)data_mm7 + 4, num_mm7_monsters * sizeof(MonsterDesc));
@@ -496,7 +498,7 @@
   v2 = fopen("data\\dmonlist.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dmonlist.bin!");
+    Error("Unable to save dmonlist.bin!");
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pMonsters, 0x98u, v1->uNumMonsters, v3);
   fclose(v3);
@@ -1193,7 +1195,7 @@
         if( (!_stricmp(pMonsters[i].pMonsterName, pMonsterName)))
             return i;
     }
-    assert(false && "Monster not found!");
+    Error("Monster not found: %s", pMonsterName);
 }
 //----- (00438BDF) --------------------------------------------------------
 bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype)
--- a/OSAPI.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/OSAPI.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -39,3 +39,11 @@
   //__debugbreak();
   return 0;
 }
+
+
+
+
+void MsgBox(const wchar_t *msg, const wchar_t *title)
+{
+  MessageBoxW(nullptr, msg, title, 0);
+}
\ No newline at end of file
--- a/OSAPI.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/OSAPI.h	Sat Sep 07 21:14:48 2013 +0200
@@ -1,5 +1,4 @@
 #define WIN32_LEAN_AND_MEAN
-#include <assert.h>
 #include <windows.h>
 
 #include <MMSystem.h>
--- a/ObjectList.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/ObjectList.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -3,6 +3,7 @@
 #include "Sprites.h"
 #include "FrameTableInc.h"
 #include "Allocator.h"
+#include "ErrorHandling.h"
 
 //----- (0042EB42) --------------------------------------------------------
 __int16 ObjectList::ObjectIDByItemID(unsigned __int16 uItemID)
@@ -49,7 +50,7 @@
   v2 = fopen("data\\dobjlist.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dobjlist.bin!");
+    Error("Unable to save dobjlist.bin!");
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pObjects, 0x38u, v1->uNumObjects, v3);
   fclose(v3);
@@ -63,8 +64,8 @@
        num_mm8_objs = data_mm8 ? *(int *)data_mm8 : 0;
 
   uNumObjects = num_mm6_objs + num_mm7_objs + num_mm8_objs;
-  assert(uNumObjects);
-  assert(!num_mm8_objs);
+  Assert(uNumObjects);
+  Assert(!num_mm8_objs);
 
   pObjects = (ObjectDesc *)pAllocator->AllocNamedChunk(pObjects, uNumObjects * sizeof(ObjectDesc), "Obj Descrip");
   memcpy(pObjects, (char *)data_mm7 + 4, num_mm7_objs * sizeof(ObjectDesc));
@@ -148,7 +149,8 @@
   v4 = fopen(Args, "r");
   File = v4;
   if ( !v4 )
-    Abortf("ObjectDescriptionList::load - Unable to open file: %s.");
+    Error("ObjectDescriptionList::load - Unable to open file: %s.");
+
   v5 = 0;
   Argsa = 0;
   if ( fgets(&Buf, 490, v4) )
@@ -168,7 +170,8 @@
   v6 = pAllocator->AllocNamedChunk(v2->pObjects, 56 * v5, "Obj Descrip");
   v2->pObjects = (ObjectDesc *)v6;
   if ( v6 == (void *)v3 )
-    Abortf("ObjectDescriptionList::load - Out of Memory!");
+    Error("ObjectDescriptionList::load - Out of Memory!");
+
   memset(v6, v3, 56 * v2->uNumObjects);
   v7 = File;
   v2->uNumObjects = v3;
--- a/Outdoor.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Outdoor.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "stru6.h"
 #include "Weather.h"
 #include "Sprites.h"
@@ -108,7 +106,6 @@
   pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;
   if (bRedraw || pRenderer->pRenderD3D)
   {
-    ResetPolygons();
     pOutdoorCamera->RotationToInts();
     sub_481ED9_MessWithOutdoorCamera();
   }
@@ -1158,7 +1155,7 @@
   void *v5; // ST14_4@1
   void *v6; // eax@1
   unsigned int v7; // eax@1
-  char v8; // zf@1
+  //char v8; // zf@1
 
   v1 = this;
   strcpy(this->pLevelFilename, "blank");
@@ -1199,12 +1196,13 @@
   v1->uSky_TextureID = pBitmaps_LOD->LoadTexture(v1->pSkyTextureName);
   strcpy(v1->pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture.data());
   v7 = pBitmaps_LOD->LoadTexture(v1->pGroundTileset);
-  v8 = v1->uSky_TextureID == -1;
   v1->uMainTile_BitmapID = v7;
-  if ( v8 )
-    Abortf("Invalid Sky Tex Handle");
+
+  if ( v1->uSky_TextureID == -1 )
+    Error("Invalid Sky Tex Handle");
+
   if ( v1->uMainTile_BitmapID == -1 )
-    Abortf("Invalid Ground Tex Handle");
+    Error("Invalid Ground Tex Handle");
 }
 
 
@@ -1714,7 +1712,7 @@
   assert(sizeof(BSPModel) == 188);
 
   if (!pGames_LOD->DoesContainerExist(pFilename))
-    Abortf("Unable to find %s in Games.LOD", pFilename);
+    Error("Unable to find %s in Games.LOD", pFilename);
 
 
   char pMinimapTextureFilename[1024];
--- a/Outdoor_stuff.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/Outdoor_stuff.h	Sat Sep 07 21:14:48 2013 +0200
@@ -68,13 +68,13 @@
 #pragma pack(push, 1)
 struct stru149
 {
-  int _48616B(int a2, int a3, int a4, int a5, int a6, int a7);
-  int _48653D(int a2, int a3, int a4, int a5, int a6, int a7);
-  void Inverse_sky_48694B();
+  void _48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7);
+  void _48653D_frustum_blv(int a2, int a3, int a4, int a5, int a6, int a7);
+  void _48694B_frustum_sky();
 
   int field_0_party_dir_x;
   int field_4_party_dir_y;
-  int field_8;
+  int field_8_party_dir_z;
   int field_C;
   int field_10;
   int field_14;
--- a/Overlays.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Overlays.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -176,7 +176,7 @@
   v2 = fopen("data\\doverlay.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save doverlay.bin!");
+    Error("Unable to save doverlay.bin!");
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pOverlays, 8u, v1->uNumOverlays, v3);
   fclose(v3);
@@ -190,8 +190,8 @@
        num_mm8_overlays = data_mm8 ? *(int *)data_mm8 : 0;
 
   uNumOverlays = num_mm6_overlays + num_mm7_overlays + num_mm8_overlays;
-  assert(uNumOverlays);
-  assert(!num_mm8_overlays);
+  Assert(uNumOverlays);
+  Assert(!num_mm8_overlays);
 
   pOverlays = (OverlayDesc *)pAllocator->AllocNamedChunk(pOverlays, uNumOverlays * sizeof(OverlayDesc), "Ovl Des.");
   memcpy(pOverlays,                                       (char *)data_mm7 + 4, num_mm7_overlays * sizeof(OverlayDesc));
@@ -230,7 +230,8 @@
   v4 = fopen(Args, "r");
   File = v4;
   if ( !v4 )
-    Abortf("ObjectDescriptionList::load - Unable to open file: %s.");
+    Error("ObjectDescriptionList::load - Unable to open file: %s.");
+
   v5 = 0;
   Argsa = 0;
   if ( fgets(&Buf, 490, v4) )
@@ -251,7 +252,8 @@
   v7 = pAllocator->AllocNamedChunk(v6, 8 * v5, "Ovl Des.");
   v2->pOverlays = (OverlayDesc *)v7;
   if ( v7 == (void *)v3 )
-    Abortf("OverlayDescriptionList::load - Out of Memory!");
+    Error("OverlayDescriptionList::load - Out of Memory!");
+
   memset(v7, v3, 8 * v2->uNumOverlays);
   v8 = File;
   v2->uNumOverlays = v3;
--- a/PaletteManager.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/PaletteManager.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "PaletteManager.h"
 #include "Texture.h"
 #include "Game.h"
@@ -423,7 +421,7 @@
       }
       else if (v23 == 0)
         Log::Warning(L"Calling palette manager with num_target_bits == 0");
-      else assert(false);
+      else Error("(%u)", v23);
       //v24 = (unsigned __int32)a3 | ((unsigned __int32)a2a << v2->uNumTargetBBits) | ((unsigned __int32)a1 << (v2->uNumTargetBBits + v2->uNumTargetGBits));
       //v25 = v73;
       //v73 += 2;
@@ -472,7 +470,7 @@
       }
       else if (v23 == 0)
         Log::Warning(L"Calling palette manager with num_target_bits == 0");
-      else assert(false);
+      else Error("(%u)", v23);
 
       //v29 = (unsigned __int64)(signed __int64)a3 | ((unsigned __int16)(signed __int64)a2a << v2->uNumTargetBBits) | (unsigned __int16)((unsigned __int16)(signed __int64)a1 << (v2->uNumTargetBBits + v28));
       //v30 = (__int16 *)v73;
@@ -517,7 +515,7 @@
     }
       else if (v23 == 0)
         Log::Warning(L"Calling palette manager with num_target_bits == 0");
-    else assert(false);
+    else Error("(%u)", v23);
 
     v36 = (signed __int64)((a1 + a2a + a3) * 0.3333333333333333 * 8.0);
     v37 = (signed int)v36 >> (8 - v2->uNumTargetRBits);
@@ -593,7 +591,7 @@
       }
       else if (v23 == 0)
         Log::Warning(L"Calling palette manager with num_target_bits == 0");
-      else assert(false);
+      else Error("(%u)", v23);
 
       if (pPalette_mistColor[0] || pPalette_mistColor[1] || pPalette_mistColor[2])
       {
--- a/Party.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Party.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "Party.h"
 #include "MapInfo.h"
 #include "Time.h"
@@ -82,7 +80,7 @@
     uFallSpeed = 0;
     field_28 = 0;
     uDefaultPartyHeight = 120;
-    field_14 = 37;
+    field_14_radius = 37;
     y_rotation_granularity = 25;
     y_rotation_speed = 90;
 
@@ -895,7 +893,7 @@
   this->uFallSpeed = 0;
   this->field_28 = 0;
   this->uDefaultPartyHeight = 120;
-  this->field_14 = 37;
+  this->field_14_radius = 37;
   this->y_rotation_granularity = 25;
   this->uWalkSpeed = 384;
   this->y_rotation_speed = 90;
@@ -1022,7 +1020,7 @@
         case Condition_Paralyzed:   player->expression = CHARACTER_EXPRESSION_PARALYZED; break;
         case Condition_Unconcious:  player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break;
         default:
-          assert(false);
+          Error("Invalid condition: %u", condition);
       }
     }
   }
@@ -1041,7 +1039,7 @@
       hireling->evt_B = 0;
       hireling->evt_C = 0;
 
-      assert(sizeof(NPCData) == 0x4C);
+      Assert(sizeof(NPCData) == 0x4C);
       memset(hireling, 0, sizeof(*hireling));
 
       pParty->field_709 = 0;
--- a/Party.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/Party.h	Sat Sep 07 21:14:48 2013 +0200
@@ -219,7 +219,7 @@
   unsigned int uDefaultPartyHeight;
   int sEyelevel;
   unsigned int uDefaultEyelevel;
-  int field_14;
+  int field_14_radius;
   int y_rotation_granularity;
   unsigned int uWalkSpeed;
   int y_rotation_speed;  // deg/s
--- a/Player.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Player.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,11 +2,8 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "stru6.h"
 
-
 #include "Player.h"
 #include "PlayerFrameTable.h"
 #include "AudioPlayer.h"
@@ -343,7 +340,7 @@
 int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier)
 {
   uint price = (uint)(((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100);
-  assert (price > 0);
+  Assert (price > 0);
 
   if (price < uRealValue)
     price = uRealValue;
@@ -650,7 +647,7 @@
         return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 79));
         break;
       default:
-        assert("Should not be able to get here" && false);
+        Error("Should not be able to get here (%u)", uClass);
         break;
     }
     return false;
@@ -813,11 +810,8 @@
     texture->Release();
     pIcons_LOD->SyncLoadedFilesCount();
   }
-  if ( slotHeight == 0 || slotWidth == 0)
-  {
-    assert("Items should have nonzero dimensions" && false);
-    return 1;
-  }
+
+    assert("Items should have nonzero dimensions");
   if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT )
   {
       for (unsigned int x = 0; x < slotWidth; x++)
@@ -1078,7 +1072,7 @@
         return 4;
     break;
     default:
-      assert(false);
+      Error("(%u)", building_type);
     break;
   }
   if (pItem->Stolen())
@@ -1103,7 +1097,7 @@
       price = this->GetPriceRepair(itemValue, multiplier);
       break;
     default:
-      assert(false);
+      Assert("(%u)", ShopMenuType);
     break;
   }
   if ( merchantLevel )
@@ -2836,7 +2830,7 @@
     }
     else
     {
-      assert(false && "Unknown armour type"); // what kind of armour is that?
+      Error("Unknown armour type"); // what kind of armour is that?
       armour_recovery_multipliers[0] = 1.0f;
       armour_recovery_multipliers[1] = 1.0f;
       armour_recovery_multipliers[2] = 1.0f;
@@ -3230,7 +3224,7 @@
 //----- (0048E96A) --------------------------------------------------------
 void Player::SetRecoveryTime(signed int rec)
 {
-  assert(rec >= 0);
+  Assert(rec >= 0);
 
   if (rec > uTimeToRecovery)
     uTimeToRecovery = rec;
@@ -4677,7 +4671,7 @@
     case 3: return mult3;
     case 4: return mult4;
   }
-  assert(false);
+  Error("(%u)", masteryLvl);
   return 0;
 }
 //----- (00490109) --------------------------------------------------------
@@ -4760,7 +4754,7 @@
     case 0x18u:
       return SEX_FEMALE;
   }
-  assert(false);
+  Error("(%u)", this->uVoiceID);
   return SEX_MALE;
 }
 
@@ -5104,9 +5098,7 @@
   case 6:
     statToChange = &this->uLuck;
   default:
-    assert(false);
-    return;
-    break;
+    Error("(%u)", eAttribute);
   }
   if ( *statToChange < baseValue )
   {
@@ -6414,7 +6406,8 @@
       break;
     }
   }
-  assert(currPlayerId != -1);
+
+  Assert(currPlayerId != -1);
   if ( var_type > VAR_AutoNotes )
   {
     if ( var_type <= VAR_GoldInBank )
@@ -6865,14 +6858,14 @@
         this->sResDarkBonus = (unsigned __int8)var_value;
         break;
       case VAR_PhysicalResistanceBonus:
-        assert("VAR_PhysicalResistanceBonus variable unsupported" && false);
+        Assert("VAR_PhysicalResistanceBonus variable unsupported" && false);
         return;
         break;
       case VAR_MagicResistanceBonus:
         this->sResMagicBonus = (unsigned __int8)var_value;
         break;
       default:
-          assert("Unexpected var_type" && false);
+          Assert("Unexpected var_type: %u", var_type);
           return;
         break;
     }
@@ -7619,7 +7612,7 @@
         pParty->uNumArenaLordWins -= (char)pValue;
         break;
     }
-    assert(false && "Function not returning any value!");
+    Error("Function not returning any value! (%u)", VarNum);
   }
   else
   {
@@ -8201,7 +8194,7 @@
       //pPlayers = &::pPlayers[1];
       //v5 = 604;
       //while ( 1 )
-  assert ( a1 > 0 && a1 < 5 );
+  Assert ( a1 > 0 && a1 < 5 );
       for ( uint i = 1; i < 5; ++i )
       {
         //item_flag = Player_has_item(604, *pPlayers, 0);
--- a/Render.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Render.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "Outdoor_stuff.h"
 #include "VideoPlayer.h"
 #include "Sprites.h"
@@ -3185,13 +3183,15 @@
       else
       {
         if ( !v7->bIsDeviceCompatible )
-          Abortf("There aren't any D3D devices to create.");
+          Error("There aren't any D3D devices to create.");
+
         v8 = pRenderD3D->CreateDevice(0, 0, hWnd);
         uAcquiredDirect3DDevice = 0;
       }
     }
     if ( !v8 )
-      Abortf("D3Drend->Init failed.");
+      Error("D3Drend->Init failed.");
+
     v9 = pRenderD3D;
     pBackBuffer4 = v9->pBackBuffer;
     pFrontBuffer4 = v9->pFrontBuffer;
@@ -3208,7 +3208,7 @@
       pBackBuffer4 = 0;
       pFrontBuffer4 = 0;
       pDirectDraw4 = 0;
-      Abortf("Direct3D renderer:  The device failed to return capabilities.");
+      Error("Direct3D renderer:  The device failed to return capabilities.");
     }
     if ( v10 & 0x3E )
     {
@@ -3222,7 +3222,7 @@
       pBackBuffer4 = 0;
       pFrontBuffer4 = 0;
       pDirectDraw4 = 0;
-      Abortf("Direct3D renderer:  The device doesn't support the necessary alpha blending modes.");
+      Error("Direct3D renderer:  The device doesn't support the necessary alpha blending modes.");
     }
     if ( (v10 & 0x80u) != 0 )
     {
@@ -3235,7 +3235,7 @@
       pBackBuffer4 = 0;
       pFrontBuffer4 = 0;
       pDirectDraw4 = 0;
-      Abortf("Direct3D renderer:  The device doesn't support non-square textures.");
+      Error("Direct3D renderer:  The device doesn't support non-square textures.");
     }
     LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1;
     bRequiredTextureStagesAvailable = CheckTextureStages();
@@ -3407,12 +3407,13 @@
     else
     {
       if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible )
-        Abortf("There aren't any D3D devices to init.");
+        Error("There aren't any D3D devices to init.");
+
       v7 = pRenderD3D->CreateDevice(0, 1, hWnd);
       uAcquiredDirect3DDevice = 0;
     }
     if ( !v7 )
-      Abortf("D3Drend->Init failed.");
+      Error("D3Drend->Init failed.");
 
     //v8 = pRenderD3D;
     pColorKeySurface4 = 0;
@@ -3431,7 +3432,7 @@
       pBackBuffer4 = 0;
       pFrontBuffer4 = 0;
       pDirectDraw4 = 0;
-      Abortf("Direct3D renderer:  The device failed to return capabilities.");
+      Error("Direct3D renderer:  The device failed to return capabilities.");
     }
     if ( v9 & 0x3E )
     {
@@ -3445,7 +3446,7 @@
       pBackBuffer4 = 0;
       pFrontBuffer4 = 0;
       pDirectDraw4 = 0;
-      Abortf("Direct3D renderer:  The device doesn't support the necessary alpha blending modes.");
+      Error("Direct3D renderer:  The device doesn't support the necessary alpha blending modes.");
     }
     if ( (v9 & 0x80u) != 0 )
     {
@@ -3458,7 +3459,7 @@
       pBackBuffer4 = 0;
       pFrontBuffer4 = 0;
       pDirectDraw4 = 0;
-      Abortf("Direct3D renderer:  The device doesn't support non-square textures.");
+      Error("Direct3D renderer:  The device doesn't support non-square textures.");
     }
     LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1;
     bRequiredTextureStagesAvailable = CheckTextureStages();
@@ -5145,7 +5146,7 @@
   v7 = pFace->uPolygonType;
   if ( v7 == 4 || v7 == 3 )
     v70 = v6;
-  stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
+  stru_8019C8._48653D_frustum_blv(65536, 0, 0, 0, 65536, 0);
   v62.Create_48607B(&stru_8019C8);
   v62.uTileBitmapID = pFace->uBitmapID;
   v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
@@ -6449,7 +6450,7 @@
             true,
             bMipMaps,
             uMinDeviceTextureDim) )
-      Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
+      Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
     //v10 = *pOutSurface;
     //v11 = 0;
     if ( bMipMaps )
@@ -6550,7 +6551,7 @@
     //v6 = v3->uMinDeviceTextureDim;
     //v7 = v3->pRenderD3D;
     if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim))
-      Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
+      Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
     //pSprite = v2->pTextureSurface;
     //pSprite = (Sprite *)pSprite->pName;
     //v8 = pSprite;
@@ -8411,7 +8412,6 @@
       ClipCursor(0);
       pRenderer->SwitchToWindow(hWnd);
       SetWindowLongA(hWnd, -16, uWindowStyle);
-      SetMenu(hWnd, hOSMenu);
     }
     if ( pRenderer->pRenderD3D )
     {
--- a/SaveLoad.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/SaveLoad.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -4,7 +4,6 @@
 
 #include <io.h>
 #include <direct.h>
-#include <assert.h>
 
 #include "SaveLoad.h"
 #include "BSPModel.h"
@@ -105,7 +104,7 @@
     Log::Warning(L"%S", Str);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0);
   }
-  assert(sizeof(SavegameHeader) == 100);
+  Assert(sizeof(SavegameHeader) == 100);
   fread(&header, sizeof(SavegameHeader), 1, f);
 
   f = pNew_LOD->FindContainer("party.bin", 1);
@@ -211,10 +210,7 @@
   sprintf(pTmpBuf.data(), "levels\\%s", header.pLocationName);
   v26 = _access(pTmpBuf.data(), 4) != -1;
   if ( !v25 && !v26 )
-  {
-    sprintf(pTmpBuf.data(), "Unable to find: %s!", header.pLocationName);
-    Abortf(pTmpBuf.data());
-  }
+    Error("Unable to find: %s!", header.pLocationName);
 
   strcpy(pCurrentMapName, header.pLocationName);
   dword_6BE364_game_settings_1 |= 0x2001;
@@ -308,7 +304,7 @@
     MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
   }
 
-  assert(sizeof(SavegameHeader) == 100);
+  Assert(sizeof(SavegameHeader) == 100);
   memset(save_header.pName, 0, 20);
   memset(save_header.pLocationName, 0, 20);
   memset(save_header.field_30, 0, 52);
@@ -344,7 +340,7 @@
   }
   strcpy(pLodDirectory.pFilename, "npcdata.bin");
   pLodDirectory.uDataSize = 501 * sizeof(NPCData);
-  assert(pLodDirectory.uDataSize == 38076);
+  Assert(pLodDirectory.uDataSize == 38076);
   if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) )
   {
     sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205);
@@ -737,15 +733,15 @@
       {
         //uint src_y = (game_viewport_y + y * v25) * (Dst.lPitch / sizeof(short));
         uint src_y = game_viewport_y + y * v25;
-        assert(game_viewport_y + y * v25 < src_height);
-        assert(y < height);
+        Assert(game_viewport_y + y * v25 < src_height);
+        Assert(y < height);
 
         for (uint x = 0; x < width; ++x)
         {
           //uint src_x = game_viewport_x + x * v23;
           uint src_x = game_viewport_x + x * v23;
-          assert(src_x < src_width);
-          assert(x < width);
+          Assert(src_x < src_width);
+          Assert(x < width);
 
           dst[y * width + x] = (((63*y)/117) << 5) | 31*x/155;//31*y/117;//src[src_y * src_width + src_x];
         }
--- a/SpriteObject.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/SpriteObject.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1,5 +1,3 @@
-#include <assert.h>
-
 #include "BSPModel.h"
 #include "SpriteObject.h"
 #include "Party.h"
@@ -312,12 +310,12 @@
       ODM_GetTerrainNormalAt(v12, v11, &v51);
       v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
       v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16;
-      v60 = ((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
-      v1->vVelocity.x += (unsigned int)(v56 * v51.x) >> 16;
-      v60 = ((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16);
-      v1->vVelocity.y += (unsigned int)(v56 * v51.y) >> 16;
-      v60 = ((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16);
-      v1->vVelocity.z += (unsigned int)(v56 * v51.z) >> 16;
+      //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
+      v1->vVelocity.x += fixpoint_sub0(v56, v51.x);
+      //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16);
+      v1->vVelocity.y += fixpoint_sub0(v56, v51.y);
+      //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16);
+      v1->vVelocity.z += fixpoint_sub0(v56, v51.z);
 LABEL_12:
       v7 = v54;
       goto LABEL_13;
@@ -397,22 +395,22 @@
     stru_721530.field_0 = 0;
     v55 = 0;
     stru_721530.prolly_normal_d = v2->uRadius;
-    stru_721530.field_C = v2->uHeight;
-    stru_721530.field_8 = 0;
+    stru_721530.height = v2->uHeight;
+    stru_721530.field_8_radius = 0;
     stru_721530.field_70 = 0;
     while ( 1 )
     {
-      stru_721530.field_34.x = v1->vPosition.x;
-      stru_721530.normal.x = stru_721530.field_34.x;
+      stru_721530.position.x = v1->vPosition.x;
+      stru_721530.normal.x = stru_721530.position.x;
       v15 = v1->vPosition.y;
       stru_721530.uSectorID = 0;
-      stru_721530.field_34.y = v15;
+      stru_721530.position.y = v15;
       stru_721530.normal.y = v15;
-      stru_721530.field_34.z = v1->vPosition.z + stru_721530.prolly_normal_d + 1;
-      stru_721530.normal.z = stru_721530.field_34.z;
-      stru_721530.field_1C = v1->vVelocity.x;
-      stru_721530.field_20 = v1->vVelocity.y;
-      stru_721530.field_24 = v1->vVelocity.z;
+      stru_721530.position.z = v1->vPosition.z + stru_721530.prolly_normal_d + 1;
+      stru_721530.normal.z = stru_721530.position.z;
+      stru_721530.velocity.x = v1->vVelocity.x;
+      stru_721530.velocity.y = v1->vVelocity.y;
+      stru_721530.velocity.z = v1->vVelocity.z;
       if ( stru_721530._47050A(0) )
         return;
       _46E889_collide_against_bmodels(0);
@@ -504,13 +502,13 @@
             }
         return;
       }
-      v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
-      v1->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-      v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
-      v1->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-      v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
+      //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16);
+      v1->vPosition.x += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x);
+      //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16);
+      v1->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y);
+      //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16);
       v28 = LOWORD(stru_721530.uSectorID);
-      v1->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
+      v1->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z);
       v29 = v1->vPosition.z;
       v1->uSectorID = v28;
       stru_721530.field_70 += stru_721530.field_7C;
@@ -532,14 +530,13 @@
         {
           v56 = abs(v32->pFacePlane.vNormal.z * v1->vVelocity.z + v32->pFacePlane.vNormal.y * v1->vVelocity.y
                                                                 + v32->pFacePlane.vNormal.x * v1->vVelocity.x) >> 16;
-          if ( stru_721530.field_64 >> 3 > v56 )
-            v56 = stru_721530.field_64 >> 3;
+          if ( (stru_721530.speed >> 3) > v56 )
+            v56 = stru_721530.speed >> 3;
           v57 = v32->pFacePlane.vNormal.x;
           v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16;
           v58 = v32->pFacePlane.vNormal.y;
           v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16;
-          v60 = v32->pFacePlane.vNormal.z;
-          v60 = ((unsigned __int64)(v56 * (signed __int64)(signed int)v60) >> 16);
+          v60 = ((unsigned __int64)(v56 * (signed __int64)v32->pFacePlane.vNormal.z) >> 16);
           v1->vVelocity.x += 2 * v57;
           v1->vVelocity.y += 2 * v58;
           if ( v32->pFacePlane.vNormal.z <= 32000 )
@@ -614,7 +611,7 @@
   int v9; // ecx@16
   __int16 v10; // di@18
   char v11; // al@19
-  int v12; // eax@25
+  //int v12; // eax@25
   int v13; // eax@31
   int v14; // ebx@34
   signed int v15; // ebx@46
@@ -673,22 +670,22 @@
     stru_721530.field_0 = v8;
     uFaceID = v8;
     stru_721530.prolly_normal_d = pObject->uRadius;
-    v12 = pObject->uHeight;
+
     stru_721530.field_84 = -1;
-    stru_721530.field_C = v12;
-    stru_721530.field_8 = v8;
+    stru_721530.height = pObject->uHeight;
+    stru_721530.field_8_radius = v8;
     stru_721530.field_70 = v8;
     while ( 1 )
     {
-      stru_721530.field_34.x = pSpriteObject->vPosition.x;
-      stru_721530.normal.x = stru_721530.field_34.x;
-      stru_721530.field_34.y = pSpriteObject->vPosition.y;
-      stru_721530.normal.y = stru_721530.field_34.y;
-      stru_721530.field_34.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1;
-      stru_721530.normal.z = stru_721530.field_34.z;
-      stru_721530.field_1C = pSpriteObject->vVelocity.x;
-      stru_721530.field_20 = pSpriteObject->vVelocity.y;
-      stru_721530.field_24 = pSpriteObject->vVelocity.z;
+      stru_721530.position.x = pSpriteObject->vPosition.x;
+      stru_721530.normal.x = stru_721530.position.x;
+      stru_721530.position.y = pSpriteObject->vPosition.y;
+      stru_721530.normal.y = stru_721530.position.y;
+      stru_721530.position.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1;
+      stru_721530.normal.z = stru_721530.position.z;
+      stru_721530.velocity.x = pSpriteObject->vVelocity.x;
+      stru_721530.velocity.y = pSpriteObject->vVelocity.y;
+      stru_721530.velocity.z = pSpriteObject->vVelocity.z;
       stru_721530.uSectorID = pSpriteObject->uSectorID;
       if ( stru_721530._47050A(v8) )
         return;
@@ -788,12 +785,12 @@
         pGame->pParticleEngine->AddParticle(&Dst);
         return;
       }
-      v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-      pSpriteObject->vPosition.x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-      v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-      pSpriteObject->vPosition.y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-      v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
-      pSpriteObject->vPosition.z += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
+      //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
+      pSpriteObject->vPosition.x += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x);
+      //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16;
+      pSpriteObject->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y);
+      //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16;
+      pSpriteObject->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z);
       pSpriteObject->uSectorID = LOWORD(stru_721530.uSectorID);
       stru_721530.field_70 += stru_721530.field_7C;
       if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
@@ -824,8 +821,8 @@
         {
           v42 = abs(v16->pFacePlane_old.vNormal.x * pSpriteObject->vVelocity.x + v16->pFacePlane_old.vNormal.z * pSpriteObject->vVelocity.z
                                                                     + v16->pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y) >> 16;
-          if ( stru_721530.field_64 >> 3 > v42 )
-            v42 = stru_721530.field_64 >> 3;
+          if ( (stru_721530.speed >> 3) > v42 )
+            v42 = stru_721530.speed >> 3;
           v40 = v16->pFacePlane_old.vNormal.x;
           v40 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16;
           v41 = v16->pFacePlane_old.vNormal.y;
--- a/SpriteObject.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/SpriteObject.h	Sat Sep 07 21:14:48 2013 +0200
@@ -3,7 +3,8 @@
 
 enum
 {
-  OBJECT_ATTACHED_TO_ACTOR = 0x80,
+    OBJECT_40 = 0x40
+  , OBJECT_ATTACHED_TO_ACTOR = 0x80
 };
 
 #define MAX_SPRITE_OBJECTS 1000
--- a/Sprites.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Sprites.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -351,7 +351,7 @@
   v2 = fopen("data\\dsft.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dsft.bin!");
+    Error("Unable to save dsft.bin!");
   fwrite(v1, 4u, 1u, v2);
   fwrite(&v1->uNumEFrames, 4u, 1u, v3);
   fwrite(v1->pSpriteSFrames, 0x3Cu, v1->uNumSpriteFrames, v3);
@@ -405,8 +405,7 @@
     pSpriteSFrames[num_mm7_frames + i].uAnimLength = 0;
   }
   memcpy(pSpriteEFrames + num_mm7_frames, (char *)data_mm6 + 8 + mm6_frames_size, 2 * num_mm6_eframes);
-  
-  if (data_mm8) __debugbreak();
+
   auto mm8_frames_size = num_mm8_frames * sizeof(SpriteFrame);
   memcpy(pSpriteSFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8, mm8_frames_size);
   memcpy(pSpriteEFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8 + mm8_frames_size, 2 * num_mm8_eframes);
@@ -479,7 +478,8 @@
   v3 = fopen(Args, "r");
   File = v3;
   if ( !v3 )
-    Abortf("CSpriteFrameTable::load - Unable to open file: %s.", Args);
+    Error("CSpriteFrameTable::load - Unable to open file: %s.", Args);
+
   v4 = 0;
   Argsa = 0;
   if ( fgets(Buf, 490, v3) )
@@ -779,16 +779,16 @@
                                 v12 = v8 - stru_721530.normal.x;
                                 v19 = v9 - stru_721530.normal.y;
                                 v13 = stru_721530.prolly_normal_d + v7;
-                                v21 = ((v8 - stru_721530.normal.x) * stru_721530.field_58.y
-                                     - (v9 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
+                                v21 = ((v8 - stru_721530.normal.x) * stru_721530.direction.y
+                                     - (v9 - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
                                 if ( abs(v21) <= stru_721530.prolly_normal_d + v7 )
                                 {
-                                  v14 = (v12 * stru_721530.field_58.x + v19 * stru_721530.field_58.y) >> 16;
+                                  v14 = (v12 * stru_721530.direction.x + v19 * stru_721530.direction.y) >> 16;
                                   if ( v14 > 0 )
                                   {
                                     v15 = v5->vPosition.z;
                                     v16 = stru_721530.normal.z
-                                        + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v14) >> 16);
+                                        + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v14) >> 16);
                                     if ( v16 >= v15 )
                                     {
                                       if ( v16 <= v22 + v15 )
--- a/Texture.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Texture.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -257,7 +257,7 @@
   v2 = fopen("data\\dtft.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dtft.bin!");
+    Error("Unable to save dtft.bin!");
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pTextures, 0x14u, v1->sNumTextures, v3);
   fclose(v3);
@@ -271,8 +271,8 @@
        num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0;
 
   sNumTextures = num_mm6_frames + num_mm7_frames + num_mm8_frames;
-  assert(sNumTextures);
-  assert(!num_mm8_frames);
+  Assert(sNumTextures);
+  Assert(!num_mm8_frames);
 
   pTextures = (TextureFrame *)pAllocator->AllocNamedChunk(pTextures, sNumTextures * sizeof(TextureFrame), "Txt Frames");
 
@@ -453,10 +453,8 @@
   v4 = v3;
   File = v3;
   if ( !v3 )
-  {
-    sprintf(pTmpBuf.data(), "Unable to load %s", pContainer);
-    Abortf(pTmpBuf.data());
-  }
+    Error("Unable to load %s", pContainer);
+
   fread(&DstBuf, 1u, 0x30u, v3);
   Count = DstBuf.uTextureSize;
   if ( DstBuf.uDecompressedSize )
@@ -543,10 +541,8 @@
   v5 = v4;
   File = v4;
   if ( !v4 )
-  {
-    sprintf(pTmpBuf.data(), "Unable to load %s", pContainer);
-    Abortf(pTmpBuf.data());
-  }
+    Error("Unable to load %s", pContainer);
+
   fread(&DstBuf, 1u, 0x30u, v4);
   Count = DstBuf.uTextureSize;
   if ( DstBuf.uDecompressedSize )
@@ -1508,7 +1504,8 @@
     fseek(File, 128, 0);
     ftell(File);
 	if ( pcx_header2.planes == 1 )
-      Abortf("24bit PCX Only!");
+      Error("24bit PCX Only!");
+
     if ( pcx_header2.planes == 3 )
     {
       v37 = 0;
@@ -1680,7 +1677,8 @@
   v3 = fopen(Args, "r");
   File = v3;
   if ( !v3 )
-    Abortf("CTextureFrameTable::load - Unable to open file: %s.", Args);
+    Error("CTextureFrameTable::load - Unable to open file: %s.", Args);
+
   v4 = 0;
   v24 = 0;
   v25 = 1;
@@ -1694,7 +1692,7 @@
       if ( v21 && *Str1 != 47 )
       {
         if ( v21 < 2 )
-          Abortf("CTextureFrameTable::load, too few arguments, %s line %i.", Args, v25);
+          Error("CTextureFrameTable::load, too few arguments, %s line %i.", Args, v25);
         ++v24;
       }
       ++v25;
@@ -1707,7 +1705,7 @@
   v6 = pAllocator->AllocNamedChunk(v5, 20 * v4, "Txt Frames");
   v2->pTextures = (TextureFrame *)v6;
   if ( !v6 )
-    Abortf("CTextureFrameTable::load - Out of Memory!");
+    Error("CTextureFrameTable::load - Out of Memory!");
   v7 = File;
   v2->sNumTextures = 0;
   fseek(v7, 0, 0);
--- a/TileTable.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/TileTable.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,7 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include  <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -30,15 +29,7 @@
 //----- (00487E3B) --------------------------------------------------------
 TileDesc *TileTable::GetTileById(unsigned int uTileID)
 {
-  /*TileDesc *result; // eax@3
-
-  if ( (uTileID & 0x80000000u) != 0 || (signed int)uTileID > (signed int)(this->uNumTiles - 1) )
-    result = this->pTiles;
-  else
-    result = &this->pTiles[uTileID];
-  return result;*/
-
-  assert(uTileID < sNumTiles);
+  Assert(uTileID < sNumTiles);
   return &pTiles[uTileID];
 }
 
@@ -112,7 +103,7 @@
   v2 = fopen("data\\dtile.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dtile.bin!");
+    Error("Unable to save dtile.bin!");
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pTiles, 0x1Au, v1->sNumTiles, v3);
   fclose(v3);
@@ -125,8 +116,8 @@
        num_mm7_tiles = data_mm7 ? *(int *)data_mm7 : 0,
        num_mm8_tiles = data_mm8 ? *(int *)data_mm8 : 0;
   sNumTiles = num_mm6_tiles + num_mm7_tiles + num_mm8_tiles;
-  assert(sNumTiles);
-  assert(!num_mm8_tiles);
+  Assert(sNumTiles);
+  Assert(!num_mm8_tiles);
 
   pTiles = (TileDesc *)pAllocator->AllocNamedChunk(pTiles, sNumTiles * sizeof(TileDesc), "Tile Descrip");
   memcpy(pTiles,                                 (char *)data_mm7 + 4, num_mm7_tiles * sizeof(TileDesc));
@@ -226,7 +217,7 @@
   v3 = fopen(pFilename, "r");
   File = v3;
   if ( !v3 )
-    Abortf("TileTable::load - Unable to open file: %s.");
+    Error("TileTable::load - Unable to open file: %s.");
   v4 = 0;
   for ( i = v3; fgets(&Buf, 490, i); i = File )
   {
@@ -239,7 +230,7 @@
   v5 = pAllocator->AllocNamedChunk(v2->pTiles, 26 * v4, "Tile Descrip");
   v2->pTiles = (TileDesc *)v5;
   if ( !v5 )
-    Abortf("TileTable::Load - Out of Memory!");
+    Error("TileTable::Load - Out of Memory!");
   memset(v5, 0, 26 * v2->sNumTiles);
   v2->sNumTiles = 0;
   fseek(File, 0, 0);
--- a/TurnEngine.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/TurnEngine.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -697,7 +697,7 @@
 
 //----- (00406648) --------------------------------------------------------
 void stru262_TurnBased::AIAttacks( unsigned int queue_index )
-    {
+{
     TurnBased_QueueElem *v1; // ecx@1
     int v3; // eax@1
     unsigned int v4; // ebx@2
--- a/UI/Books/UIMapBook.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/Books/UIMapBook.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "..\..\MM7.h"
 #include "..\..\Render.h"
 #include "..\..\Mouse.h"
--- a/UI/Books/UINotesBooks.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/Books/UINotesBooks.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1,9 +1,7 @@
-
 #ifdef _MSC_VER
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
 #include "..\..\MM7.h"
 #include "..\..\Render.h"
 #include "..\..\Mouse.h"
--- a/UI/Books/UISpellBook.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/Books/UISpellBook.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,7 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
 #include "..\..\MM7.h"
 #include "..\..\Render.h"
 #include "..\..\Mouse.h"
--- a/UI/UIBooks.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UIBooks.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,7 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
 #include "..\MM7.h"
 #include "UIBooks.h"
 #include "..\Render.h"
--- a/UI/UICharacter.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UICharacter.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,7 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
 #include <algorithm> 
 #include "..\MM7.h"
 #include "..\MapInfo.h"
--- a/UI/UIHouses.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UIHouses.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -558,7 +558,7 @@
       break;
 
     default:
-      assert(false && "Invalid enumeration value");
+      Error("Invalid enumeration value: %u", type);
   }
 
 /*  if ( a1 > 13 )
@@ -867,12 +867,12 @@
 		if ( !pIcons_LOD->uNumPrevLoadedFiles )
 			pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
 		switch (pParty->alignment)
-			{
+        {
 		case PartyAlignment_Good:    sprintf(pContainer, "evt%02d-b", const_2()); break;
 		case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break;
 		case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2()); break;
-		default: assert(false);
-			}
+        default: Error("Invalid alignment type: %u", pParty->alignment);
+        }
 
 		v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
 		pDialogueNPCCount = 0;
--- a/UI/UIMainMenu.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UIMainMenu.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,9 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
-
 #include "..\Mouse.h"
 #include "..\Keyboard.h"
 
@@ -278,7 +275,8 @@
         ptr = v0;
         pFile = pEvents_LOD->FindContainer("credits.txt", 0);
         if ( !pFile )
-            Abortf(pGlobalTXT_LocalizationStrings[63]); // "Might and Magic VII is having trouble loading files. 
+            Error(pGlobalTXT_LocalizationStrings[63]); // "Might and Magic VII is having trouble loading files. 
+
         // Please re-install to fix this problem. Note: Re-installing will not destroy your save games."
         fread(&pTexture3, 1, 0x30, pFile);
         pSize = pTexture3.uDecompressedSize;
--- a/UI/UIOptions.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UIOptions.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1,5 +1,3 @@
-#include <assert.h>
-
 #include "..\MM7.h"
 
 #include "..\Keyboard.h"
--- a/UI/UIPartyCreation.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UIPartyCreation.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,9 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
-
 #include "..\Mouse.h"
 #include "..\Keyboard.h"
 
@@ -173,7 +170,7 @@
     case 2: pX = 329; break;
     case 3: pX = 488; break;
     default:
-      assert(false && "Invalid selected character");
+      Error("Invalid selected character");
   }
 
   pTextCenter = pFontCChar->AlignText_Center(640, pGlobalTXT_LocalizationStrings[51]);
@@ -811,7 +808,7 @@
         case PLAYER_SKILL_SPEAR:   player->AddItem(-1, 31); break;
         case PLAYER_SKILL_BOW:     player->AddItem(-1, 47); break;
         case PLAYER_SKILL_MACE:    player->AddItem(-1, 50); break;
-        case PLAYER_SKILL_BLASTER: assert(false); break;
+        case PLAYER_SKILL_BLASTER: Error("No blasters at startup :p");
         case PLAYER_SKILL_SHIELD:  player->AddItem(-1, 84); break;
         case PLAYER_SKILL_LEATHER: player->AddItem(-1, 66); break;
         case PLAYER_SKILL_CHAIN:   player->AddItem(-1, 71); break;
@@ -847,7 +844,7 @@
         case PLAYER_SKILL_LIGHT:
         case PLAYER_SKILL_DARK:
         case PLAYER_SKILL_DIPLOMACY:
-          assert(false);
+          Error("No dimoplacy in mm7 (yet)");
         break;
         case PLAYER_SKILL_ITEM_ID:
         case PLAYER_SKILL_REPAIR:
--- a/UI/UIPopup.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UIPopup.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "..\MM7.h"
 
 #include "..\Mouse.h"
--- a/UI/UIRest.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UIRest.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,9 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
-
 #include "..\GUIWindow.h"
 #include "..\GUIFont.h"
 #include "..\Party.h"
--- a/UI/UISaveLoad.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UISaveLoad.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,7 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
 #include <io.h>
 #include "..\MM7.h"
 
@@ -288,7 +287,7 @@
         uLoadGameUI_SelectedSlot = 0;
         }
     pLODFile.AllocSubIndicesAndIO(0x12C, 0);
-    assert(sizeof(SavegameHeader) == 0x64);
+    Assert(sizeof(SavegameHeader) == 0x64);
     //v3 = 0;
     for (uint i = 0; i < uNumSavegameFiles; ++i)
         {
--- a/UI/UITransition.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UITransition.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,7 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
 #include <io.h>
 
 #include "..\mm7_data.h"
@@ -63,7 +62,7 @@
     case PartyAlignment_Good:    sprintfex(pContainer, "evt%02d-b", const_2()); break;
     case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2());   break;
     case PartyAlignment_Evil:    sprintfex(pContainer, "evt%02d-c", const_2()); break;
-    default: assert(false);
+    default: Error("Invalid alignment: %u", pParty->alignment);
   }
 
   v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
@@ -129,7 +128,7 @@
     case PartyAlignment_Good:    sprintfex(pContainer, "evt%02d-b", const_2()); break;
     case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2());   break;
     case PartyAlignment_Evil:    sprintfex(pContainer, "evt%02d-c", const_2()); break;
-    default: assert(false);
+    default: Error("Invalid alignment: %u", pParty->alignment);
   }
 
   pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
@@ -248,7 +247,7 @@
     v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &v8, 0, 0)) / 2 + 101;
     v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf.data(), 3);
   }
-  else assert(false);
+  else Error("Troubles in da house");
 
   _unused_5B5924_is_travel_ui_drawn = true;
 }
--- a/UI/UiGame.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/UI/UiGame.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "..\Texture.h"
 #include "..\MM7.h"
 
--- a/Viewport.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Viewport.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -95,67 +95,72 @@
 
 //----- (00443219) --------------------------------------------------------
  void ViewingParams::_443219()
-    {
-    this->sViewCenterY += 512;
-    AdjustPosition();
-    }
+ {
+   this->sViewCenterY += 512;
+   
+   AdjustPosition();
+ }
 
 //----- (00443225) --------------------------------------------------------
 void ViewingParams::_443225()
-    {
-    this->sViewCenterX -= 512;
-    AdjustPosition();
-    }
+{
+  this->sViewCenterX -= 512;
+  
+  AdjustPosition();
+}
 
 //----- (00443231) --------------------------------------------------------
 void ViewingParams::_443231()
-    {
-    this->sViewCenterY -= 512;
-    AdjustPosition();
-    }
+{
+  this->sViewCenterY -= 512;
+
+  AdjustPosition();
+}
 
 //----- (0044323D) --------------------------------------------------------
 void ViewingParams::_44323D()
-    {
-    this->sViewCenterX += 512;
-    AdjustPosition();
-    }
+{
+  this->sViewCenterX += 512;
+
+  AdjustPosition();
+}
 
 //----- (00443249) --------------------------------------------------------
 void ViewingParams::CenterOnParty()
-    {
-    int v1; // edx@1
+{
+  this->field_2C = (32768 * (__int64)this->field_2C) >> 16;
+  if (this->field_2C < 384)
+    this->field_2C = 384;
 
-    v1 = (unsigned __int64)((signed __int64)this->field_2C << 15) >> 16;
-    this->field_2C = v1;
-    if ( v1 < 384 )
-        this->field_2C = 384;
-    this->sViewCenterX = pParty->vPosition.x;
-    this->sViewCenterY = pParty->vPosition.y;
-    AdjustPosition();
-    }
+  this->sViewCenterX = pParty->vPosition.x;
+  this->sViewCenterY = pParty->vPosition.y;
+
+  AdjustPosition();
+}
 
 //----- (00443291) --------------------------------------------------------
 void ViewingParams::CenterOnParty2()
-    {
-    int v1; // edx@1
+{
     int v2; // eax@1
 
-    v1 = 2 * this->field_2C;
-    v2 = 1536;
-    this->field_2C = v1;
-    if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
-        v2 = 3072;
-    if ( v1 > v2 )
+    if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+      v2 = 1536;
+    else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+      v2 = 3072;
+    else assert(false);
+    
+    this->field_2C *= 2;
+    if (this->field_2C > v2 )
         this->field_2C = v2;
+
     this->sViewCenterX = pParty->vPosition.x;
     this->sViewCenterY = pParty->vPosition.y;
     AdjustPosition();
-    }
+}
 
 //----- (004432E7) --------------------------------------------------------
 void ViewingParams::AdjustPosition()
-    {
+{
     ViewingParams *v1; // esi@1
     int v2; // ebx@1
     signed int v3; // edx@1
@@ -167,7 +172,7 @@
 
     v1 = this;
     v2 = this->indoor_center_y;
-    v3 = 88 >> this->field_2C / 384;
+    v3 = 88 >> (this->field_2C / 384);
     v4 = (44 - v3) << 9;
     if ( v1->sViewCenterY > v2 + v4 )
         v1->sViewCenterY = v2 + v4;
--- a/Vis.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/Vis.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1,5 +1,3 @@
-#include <assert.h>
-
 #include "Vis.h"
 #include "Outdoor.h"
 #include "BSPModel.h"
@@ -592,9 +590,9 @@
   Intersection->vWorldPosition.y = pRayStart->vWorldPosition.y + t * ray_dir_x;
   Intersection->vWorldPosition.z = pRayStart->vWorldPosition.z + t * ray_dir_z;
 
-  IntersectPoint.x = (signed __int64)Intersection->vWorldPosition.x;
-  IntersectPoint.y = (signed __int64)Intersection->vWorldPosition.y;
-  IntersectPoint.z = (signed __int64)Intersection->vWorldPosition.z;
+  IntersectPoint.x = Intersection->vWorldPosition.x;
+  IntersectPoint.y = Intersection->vWorldPosition.y;
+  IntersectPoint.z = Intersection->vWorldPosition.z;
 
   if ( !CheckIntersectBModel(pFace, IntersectPoint, pBModelID) )
     return false;
@@ -883,11 +881,11 @@
   int outz; // [sp+94h] [bp-Ch]@1
   int outy; // [sp+98h] [bp-8h]@1
 
-  pRotY = pIndoorCamera->sRotationY + UnprojectX((signed __int64)fMouseX);
+  pRotY = pIndoorCamera->sRotationY + UnprojectX(fMouseX);
   pStartR.z = pIndoorCamera->pos.z;
   pStartR.x = pIndoorCamera->pos.x;
   pStartR.y = pIndoorCamera->pos.y;
-  pRotX = pIndoorCamera->sRotationX + UnprojectY((signed __int64)fMouseY);
+  pRotX = pIndoorCamera->sRotationX + UnprojectY(fMouseY);
   pDepth = fixpoint_from_float(fPickDepth);
   Vec3_int_::Rotate(pDepth, pRotY, pRotX, pStartR, &outx, &outy, &outz);
 
--- a/_deleted.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/_deleted.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2120,7 +2120,7 @@
     return;
 
   array_77EC08[1999].Create_48607B(&stru_8019C8);
-  array_77EC08[1999].ptr_38->Inverse_sky_48694B();
+  array_77EC08[1999].ptr_38->_48694B_frustum_sky();
 
   if (pOutdoor->uMainTile_BitmapID == -1)
   {
@@ -2143,7 +2143,7 @@
   cos((double)pIndoorCamera->sRotationX * 0.0030664064);
   sin((double)pIndoorCamera->sRotationX * 0.0030664064);
   array_77EC08[1999].Create_48607B(&stru_8019C8);
-  array_77EC08[1999].ptr_38->Inverse_sky_48694B();
+  array_77EC08[1999].ptr_38->_48694B_frustum_sky();
 
   if (pOutdoor->uSky_TextureID == -1)
   {
@@ -12276,6 +12276,75 @@
     while ( v16 != 1 );
   }
 }
+//----- (00481EB7) --------------------------------------------------------
+void ResetPolygons()
+{
+  for (auto i = 0; i < pOutdoorCamera->uNumPolygons; ++i)
+  {
+    array_77EC08[i].prolly_head = nullptr;
+    array_77EC08[i].prolly_tail = nullptr;
+
+    array_77EC08[i].flags = 0;
+    array_77EC08[i].field_32 = 0;
+  }
+}
+//----- (00466BE5) --------------------------------------------------------
+void Abortf(const char *Format, ...)
+{
+  va_list va; // [sp+8h] [bp+8h]@1
+
+  va_start(va, Format);
+  if ( !pRenderer->bWindowMode )
+    pRenderer->ChangeBetweenWinFullscreenModes();
+  vsprintf(pTmpBuf.data(), Format, va);
+  if ( pMouse )
+    pMouse->Activate(0);
+  ClipCursor(0);
+  MessageBoxA(0, pTmpBuf.data(), "Error", 0x30u);
+  Game_DeinitializeAndTerminate(1);
+}
+//----- (00466B8C) --------------------------------------------------------
+int  AbortWithError()
+{
+  if ( !aborting_app )
+  {
+    ClipCursor(0);
+    aborting_app = 1;
+    if ( !pRenderer->bWindowMode )
+      pRenderer->ChangeBetweenWinFullscreenModes();
+    if ( MessageBoxA(0, pGlobalTXT_LocalizationStrings[176], pGlobalTXT_LocalizationStrings[59], 0x34u) == 6 )
+      SaveGame(1, 0);                           // "Internal Error"
+                                                // "Might and Magic VII has detected an internal error and will be forced to close.  Would you like us to autosave your game before closing?"
+    Game_DeinitializeAndTerminate(1);
+  }
+  return 0;
+}
+
+//----- (0046271C) --------------------------------------------------------
+void CreateDefaultBLVLevel()
+{
+  ofn.lStructSize = 0x4Cu;
+  ofn.hwndOwner = hWnd;
+  ofn.hInstance = 0;
+  ofn.lpstrFilter = "Indoor  BLV Files (*.blv)";
+  ofn.lpstrCustomFilter = 0;
+  ofn.nMaxCustFilter = 0;
+  ofn.nFilterIndex = 0;
+  ofn.lpstrFile = 0;
+  ofn.nMaxFile = 260;
+  ofn.nMaxFileTitle = 512;
+  ofn.lpstrInitialDir = "levels";
+  ofn.lpstrTitle = "Might and Magic® VII - Load Which Level?";
+  ofn.Flags = 4;
+  ofn.nFileOffset = 0;
+  ofn.nFileExtension = 0;
+  ofn.lpstrDefExt = "blv";
+  ofn.lCustData = 0;
+  ofn.lpfnHook = 0;
+  ofn.lpTemplateName = 0;
+  ofn.lpstrFileTitle = pTmpBuf.data();
+}
+
 const wchar_t *UIMessage2String(UIMessageType msg)
 {
   #define CASE(xxx) case xxx: swprintf(b, wcslen(L"%03X/%s"), L"%03X/%s", msg, L#xxx); return b;
--- a/mm7_1.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7_1.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -9,7 +9,6 @@
 */
 
 //#include <defs.h>
-#include <assert.h>
 
 #include "Texture.h"
 #include "mm7_data.h"
@@ -68,6 +67,13 @@
   return ((__int64)a1 * (__int64)a2) >> 16;
 }
 
+int fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2)
+{
+  return fixpoint_sub0(x1, x2) +
+         fixpoint_sub0(y1, y2) +
+         fixpoint_sub0(z1, z2);
+}
+
 //----- (0041D20D) --------------------------------------------------------
 void __fastcall sub_41D20D_buff_remaining_time_string( int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2 )
     {
@@ -400,7 +406,7 @@
     v4 = 225;
     v6 = 255;
   }
-  else assert(false);
+  else Error("Invalid alignment type: %u", align);
 
   uGameUIFontMain = v3;
   uGameUIFontShadow = TargetColor(v5, v4, v6);
--- a/mm7_2.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7_2.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -4,9 +4,8 @@
 
 #include <io.h>
 #include <direct.h>
-#include <assert.h>
-#include <windows.h>
-
+
+#include "OSAPI.h"
 
 #include "Texture.h"
 #include "mm7_data.h"
@@ -3088,32 +3087,6 @@
       event_triggers[num_event_triggers++] = i;
 }
 
-OPENFILENAMEA ofn;
-//----- (0046271C) --------------------------------------------------------
-void CreateDefaultBLVLevel()
-{
-  ofn.lStructSize = 0x4Cu;
-  ofn.hwndOwner = hWnd;
-  ofn.hInstance = 0;
-  ofn.lpstrFilter = "Indoor  BLV Files (*.blv)";
-  ofn.lpstrCustomFilter = 0;
-  ofn.nMaxCustFilter = 0;
-  ofn.nFilterIndex = 0;
-  ofn.lpstrFile = 0;
-  ofn.nMaxFile = 260;
-  ofn.nMaxFileTitle = 512;
-  ofn.lpstrInitialDir = "levels";
-  ofn.lpstrTitle = "Might and Magic® VII - Load Which Level?";
-  ofn.Flags = 4;
-  ofn.nFileOffset = 0;
-  ofn.nFileExtension = 0;
-  ofn.lpstrDefExt = "blv";
-  ofn.lCustData = 0;
-  ofn.lpfnHook = 0;
-  ofn.lpTemplateName = 0;
-  ofn.lpstrFileTitle = pTmpBuf.data();
-}
-
 //----- (004627B7) --------------------------------------------------------
 void MainMenu_Loop()
 {
@@ -3254,7 +3227,7 @@
 }
 
 //----- (004637EB) --------------------------------------------------------
-LRESULT CALLBACK aWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+int __stdcall aWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
   //HANDLE v6; // eax@32
   //HDC v10; // edi@50
@@ -3270,13 +3243,12 @@
 
   switch (uMsg)
   {
-    case WM_SIZING: 
-      return 1;
-
+    case WM_SIZING: return 1;
+    
+    case WM_CREATE:  case WM_NCCREATE:
+    case WM_GETTEXT: case WM_SETTEXT:
     case WM_SHOWWINDOW:
-    case WM_GETTEXT:
-    case WM_SETTEXT:
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_DESTROY:
       SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
@@ -3288,7 +3260,7 @@
       if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer)
         BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0);
 
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
     }
 
     case WM_CHAR:
@@ -3296,13 +3268,13 @@
       if (!pKeyActionMap->_459F10(wParam) && !viewparams->field_4C)
         GUI_HandleHotkey(wParam);
     }
-    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+    return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
 
     case WM_DEVICECHANGE:
     {
       if (wParam == 0x8000)          // CD or some device has been inserted - notify InsertCD dialog
-        PostMessage(hInsertCDWindow, WM_USER + 1, 0, 0);
+        PostMessageW(hInsertCDWindow, WM_USER + 1, 0, 0);
       return 0;
     }
 
@@ -3314,7 +3286,7 @@
 
         case 101:  // Quit game
         case 40001:
-          SendMessage(hWnd, WM_DESTROY, 0, 0);
+          SendMessageW(hWnd, WM_DESTROY, 0, 0);
         return 0;
 
 
@@ -3483,14 +3455,14 @@
 
       }
     }
-    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+    return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_LBUTTONDOWN:
       if (pArcomageGame->bGameInProgress)
       {
         pArcomageGame->stru1.field_0 = 7;
         ArcomageGame::OnMouseClick(0, true);
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
 
       goto __handle_mouse_click;
@@ -3500,7 +3472,7 @@
       {
         pArcomageGame->stru1.field_0 = 8;
         ArcomageGame::OnMouseClick(1, true);
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
 
       if (pVideoPlayer->pVideoFrame.pPixels)
@@ -3514,33 +3486,33 @@
       }
 
       sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
 
     case WM_LBUTTONUP:
       if ( !pArcomageGame->bGameInProgress )
       {
         back_to_game();
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
       pArcomageGame->stru1.field_0 = 3;
       ArcomageGame::OnMouseClick(0, 0);
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
     case WM_RBUTTONUP:
       if ( !pArcomageGame->bGameInProgress )
       {
         back_to_game();
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
       pArcomageGame->stru1.field_0 = 4;
       ArcomageGame::OnMouseClick(1, false);
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_LBUTTONDBLCLK:
       if ( pArcomageGame->bGameInProgress )
       {
         pArcomageGame->stru1.field_0 = 7;
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
         
 __handle_mouse_click:
@@ -3559,7 +3531,7 @@
 
       UI_OnMouseLeftClick(0);
 
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_RBUTTONDBLCLK:
       if ( !pArcomageGame->bGameInProgress )
@@ -3575,12 +3547,12 @@
         }
 
         sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
 
       pArcomageGame->stru1.field_0 = 8;
 
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_MBUTTONDOWN:
       if (pRenderer->pRenderD3D && pGame)
@@ -3588,7 +3560,7 @@
         pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 1, &vis_sprite_filter_3, &vis_face_filter);
       }
 
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_MOUSEMOVE:
       if ( pArcomageGame->bGameInProgress )
@@ -3602,13 +3574,13 @@
         pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam));
       }
 
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_SYSCOMMAND:
       if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER )
         return 0;
 
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_KEYUP:
       if (wParam == VK_CONTROL)
@@ -3616,13 +3588,13 @@
         dword_507B98_ctrl_pressed = 0;
       }
 
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_KEYDOWN:
       if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
       {
         pKeyActionMap->_459F10(wParam);
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
       if ( !pArcomageGame->bGameInProgress )
       {
@@ -3650,7 +3622,7 @@
         {
           if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() )
             return 0;
-          SendMessage(hWnd, WM_COMMAND, 104, 0);
+          SendMessageW(hWnd, WM_COMMAND, 104, 0);
           return 0;
         }
         if ( wParam >= VK_LEFT && wParam <= VK_DOWN )
@@ -3675,15 +3647,15 @@
         pArcomageGame->field_F4 = 1;
         pArcomageGame->uGameResult = 2;
         pArcomageGame->field_B0 = -2;
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
       if ( wParam != 114 )
       {
         if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
           SendMessage(hWnd, WM_COMMAND, 0x68u, 0);
-        return DefWindowProc(hWnd, uMsg, wParam, lParam);
+        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
       }
-      SendMessage(hWnd, WM_COMMAND, 103, 0);
+      SendMessageW(hWnd, WM_COMMAND, 103, 0);
       return 0;
 
     case WM_ACTIVATEAPP:
@@ -3699,7 +3671,7 @@
             int planes = GetDeviceCaps(hDC, PLANES);
             ReleaseDC(hWnd, hDC);
             if (bitsPerPixel != 16 || planes != 1)
-              Abortf(pGlobalTXT_LocalizationStrings[62]);
+              Error(pGlobalTXT_LocalizationStrings[62]);
           }
           BYTE1(dword_6BE364_game_settings_1) &= 0xFEu;
 
@@ -3758,31 +3730,16 @@
       }
       return 0;
 
-    case WM_CREATE:
-      {
-        auto hDC = GetDC(hWnd);
-        {
-          if (GetDeviceCaps(hDC, BITSPIXEL) < 8)
-          {
-            ReleaseDC(hWnd, hDC);
-            Log::Warning(L"You must be running in 256 color mode or higher.");
-            Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon.");
-          }
-        }
-        ReleaseDC(hWnd, hDC);
-      }
-      return 0;
-
     case WM_SETFOCUS:
       dword_4E98BC_bApplicationActive = 0;
       if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 )
         SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
       ClipCursor(0);
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_KILLFOCUS:
       dword_4E98BC_bApplicationActive = 1;
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcW(hWnd, uMsg, wParam, lParam);
 
     case WM_PAINT:
       if ( !GetUpdateRect(hWnd, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
@@ -3806,7 +3763,7 @@
       return 0;
 
     default:
-      return DefWindowProc(hWnd, uMsg, wParam, lParam);
+      return DefWindowProcA(hWnd, uMsg, wParam, lParam);
   }
 }
 
@@ -3937,12 +3894,12 @@
     pSpriteObjects[i].uObjectDescID = 0;
 
   v5 = pMapStats->GetMapInfo(pCurrentMapName);
-  bUnderwater = 0;
+  bUnderwater = false;
   uLevelMapStatsID = v5;
   pGame->uFlags2 &= 0xFFFFFFF7u;
   if ( !_stricmp(pCurrentMapName, "out15.odm") )
   {
-    bUnderwater = 1;
+    bUnderwater = true;
     pGame->uFlags2 |= 8u;
   }
   pParty->floor_face_pid = 0;
@@ -4382,11 +4339,6 @@
   auto hDesktopDC = GetDC(nullptr);
   uint uDesktopWidth = GetDeviceCaps(hDesktopDC, HORZRES);
   uint uDesktopHeight = GetDeviceCaps(hDesktopDC, VERTRES);
-
-  if (GetDeviceCaps(hDesktopDC, BITSPIXEL) != 16 ||
-      GetDeviceCaps(hDesktopDC, PLANES) != 1 )
-    dword_6BE364_game_settings_1 |= 2;
-
   ReleaseDC(nullptr, hDesktopDC);
 
   uint uTotalWinWidth = 2 * GetSystemMetrics(SM_CXFRAME) + 640;
@@ -4403,14 +4355,14 @@
   uWindowY = uDesktopHeight / 2 - 480 / 2;
   WriteWindowsRegistryInt("window Y", uWindowY);
 
-  hWnd = CreateWindowEx(0, wcxw.lpszClassName, L"Might and Magic® VII",
-                        uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER,
-                        uWindowX, uWindowY,
-                        640, 480,
-                        nullptr,
-                        hOSMenu = nullptr,
-                        wcxw.hInstance,
-                        nullptr);
+  hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and Magic® VII",
+                         uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER,
+                         uWindowX, uWindowY,
+                         640, 480,
+                         nullptr,
+                         nullptr,
+                         wcxw.hInstance,
+                         nullptr);
 
   HMENU menu = CreateMenu();
   {
@@ -4671,7 +4623,7 @@
   }
 
 
-
+#if 0
   if (_access("../MM_VI/data/icons.lod", 0) == 0)
   {
     pIcons_LOD_mm6 = new LODFile_IconsBitmaps;
@@ -4714,54 +4666,48 @@
     Log::Warning(L"Unable to find mm6:sprites.lod");
 
 
-
-  if (bDebugResouces)
-  {
-    pSpriteFrameTable = new SpriteFrameTable;
-    if (!pSpriteFrameTable->FromFileTxt("data\\sft.txt"))
-      Abortf("Unable to open sft.txt");
-
-    pDecorationList = new DecorationList;
-    if (!pDecorationList->FromFileTxt("data\\declist.txt"))
-      Abortf("Unable to open declist.txt");
-
-    pObjectList = new ObjectList;
-    if (!pObjectList->FromFileTxt("data\\objlist.txt"))
-      Abortf("Unable to open objlist.txt");
-
-    pMonsterList = new MonsterList;
-    if (!pMonsterList->FromFileTxt("data\\monlist.txt"))
-      Abortf("Unable to open monlist.txt");
-
-    pIconsFrameTable = new IconFrameTable;
-    if (!pIconsFrameTable->FromFileTxt("data\\ift.txt"))
-      Abortf("Unable to open ift.txt");
-
-    pTextureFrameTable = new TextureFrameTable;
-    if (!pTextureFrameTable->FromFileTxt("data\\tft.def"))
-      Abortf("Unable to open tft.def");
-
-    pTileTable = new TileTable;
-    if (!pTileTable->FromFileTxt("data\\tile.def"))
-      Abortf("Unable to open tile.def");
-
-    pPlayerFrameTable = new PlayerFrameTable;
-    if (!pPlayerFrameTable->FromFileTxt("data\\pft.def"))
-      Abortf("Unable to open pft.def");
-
-    pChestList = new ChestList;
-    if (!pChestList->FromFileTxt("data\\chest.def"))
-      Abortf("Unable to open chest.def");
-
-    pOverlayList = new OverlayList;
-    if (!pOverlayList->FromFileTxt("data\\overlay.def"))
-      Abortf("Unable to open overlay.def");
-
-    pSoundList = new SoundList;
-    if (!pSoundList->FromFileTxt("data\\sounds.def"))
-      Abortf("Unable to open sounds.def");
+  if (_access("../mm8/data/icons.lod", 0) == 0)
+  {
+    pIcons_LOD_mm8 = new LODFile_IconsBitmaps;
+    if (!pIcons_LOD_mm8->Load("../mm8/data/icons.lod", "icons"))
+    {
+      delete pIcons_LOD_mm8;
+      pIcons_LOD_mm8 = nullptr;
+      Log::Warning(L"Unable to load mm8:icons.lod");
+    }
   }
   else
+    Log::Warning(L"Unable to find mm8:icons.lod");
+
+
+  if (_access("../mm8/data/bitmaps.lod", 0) == 0)
+  {
+    pBitmaps_LOD_mm8 = new LODFile_IconsBitmaps;
+    if (!pBitmaps_LOD_mm8->Load("../mm8/data/bitmaps.lod", "bitmaps"))
+    {
+      delete pBitmaps_LOD_mm8;
+      pBitmaps_LOD_mm8 = nullptr;
+      Log::Warning(L"Unable to load mm8:bitmaps.lod");
+    }
+  }
+  else
+    Log::Warning(L"Unable to find mm8:bitmaps.lod");
+  
+
+  if (_access("../mm8/data/sprites.lod", 0) == 0)
+  {
+    pSprites_LOD_mm8 = new LODFile_Sprites;
+    if (!pSprites_LOD_mm8->LoadSprites("../mm8/data/sprites.lod"))
+    {
+      delete pSprites_LOD_mm8;
+      pSprites_LOD_mm8 = nullptr;
+      Log::Warning(L"Unable to load mm8:sprites.lod");
+    }
+  }
+  else
+    Log::Warning(L"Unable to find mm8:sprites.lod");
+#endif
+
   {
     void *sft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsft.bin", 1) : nullptr,
          *sft_mm8 = nullptr;
@@ -4864,20 +4810,6 @@
   }
 
 
-  if (bDebugResouces)
-  {
-    pSpriteFrameTable->ToFile();
-    pDecorationList->ToFile();
-    pObjectList->ToFile();
-    pMonsterList->ToFile();
-    pIconsFrameTable->ToFile();
-    pTextureFrameTable->ToFile();
-    pTileTable->ToFile();
-    pPlayerFrameTable->ToFile();
-    pChestList->ToFile();
-    pOverlayList->ToFile();
-    pSoundList->ToFile();
-  }
 
   
   if (dword_6BE364_game_settings_1 & 2 || !(dword_6BE368_debug_settings_2 & 1))// 
@@ -5136,7 +5068,7 @@
   assert(sizeof(MobileLight) == 0x12);
   assert(sizeof(LightsStack_MobileLight_) == 0x1C28);
   assert(sizeof(Game) == 0xE78);
-  assert(sizeof(stru141) == 0xA8);
+  assert(sizeof(stru141_actor_collision_object) == 0xA8);
   assert(sizeof(ActionQueue) == 0x7C);
   assert(sizeof(NPCData) == 0x4C);
   assert(sizeof(NPCStats) == 0x17FFC);
@@ -5202,19 +5134,6 @@
 //----- (00462C94) --------------------------------------------------------
 bool MM_Main(const wchar_t *pCmdLine)
 {
-  HWND hPrevWnd; // eax@1
-  HWND hPrevWnd_; // esi@1
-  HWND v6; // eax@4
-  int v8; // eax@15
-  //bool v9; // edx@16
-  //OtherOverlay *v10; // esi@44
-  //signed int v11; // edi@44
-  //unsigned int v12; // ecx@56
-  HANDLE v13; // eax@68
-  unsigned int startms; // [sp+8h] [bp-24h]@55
-  RECT Rect; // [sp+Ch] [bp-20h]@15
-  int a2[4]; // [sp+1Ch] [bp-10h]@15
-  
   IntegrityTest();
   char test[1024];
   sprintfex(test, "^Pi[%s]: çíàõàð^R[ü;êà;]", "Çîëòàí");
@@ -5266,7 +5185,6 @@
     pGame->Deinitialize();
     return 1;
   }
-  Log::Warning(L"MM init: ok");
 
     pEventTimer->Pause();
 
@@ -5276,7 +5194,7 @@
     dword_6BE364_game_settings_1 |= 0x4000;
     pGame->InitializeGammaController();
     SecondaryInitialization();
-    pRenderer->SetRasterClipRect(0, 0, 639u, 479u);
+    pRenderer->SetRasterClipRect(0, 0, 639, 479);
     FinalInitialization();
 
     Log::Warning(L"MM: entering main loop");
@@ -5349,18 +5267,19 @@
 
 			  pParty->Reset();
 			  pParty->CreateDefaultParty(1);
-
-              extern void CreateDefaultBLVLevel();
+              
+              __debugbreak();
+              /*extern void CreateDefaultBLVLevel();
 			  CreateDefaultBLVLevel();
 
-			  extern OPENFILENAMEA ofn;
+			  OPENFILENAMEA ofn;
 			  if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
 			  {
 				pMouse->Activate(1);
 				break;
 			  }
 			  _chdir("..\\");
-			  strcpy(pCurrentMapName, ofn.lpstrFileTitle);
+			  strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/
 			  pMouse->Activate(1);
 			  pGame->Loop();
 		  }
@@ -5388,7 +5307,7 @@
       {
         pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
         AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-        unsigned int end_ms;
+        unsigned int startms, end_ms;
         AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &startms, &end_ms);
         AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms);
       }
@@ -5594,40 +5513,6 @@
     pOutdoorCamera->_485F64();
 }
 
-//----- (00466B8C) --------------------------------------------------------
-int  AbortWithError()
-{
-  if ( !aborting_app )
-  {
-    ClipCursor(0);
-    aborting_app = 1;
-    if ( !pRenderer->bWindowMode )
-      pRenderer->ChangeBetweenWinFullscreenModes();
-    if ( MessageBoxA(0, pGlobalTXT_LocalizationStrings[176], pGlobalTXT_LocalizationStrings[59], 0x34u) == 6 )
-      SaveGame(1, 0);                           // "Internal Error"
-                                                // "Might and Magic VII has detected an internal error and will be forced to close.  Would you like us to autosave your game before closing?"
-    Game_DeinitializeAndTerminate(1);
-  }
-  return 0;
-}
-// 720018: using guessed type int aborting_app;
-
-//----- (00466BE5) --------------------------------------------------------
-void Abortf(const char *Format, ...)
-{
-  va_list va; // [sp+8h] [bp+8h]@1
-
-  va_start(va, Format);
-  if ( !pRenderer->bWindowMode )
-    pRenderer->ChangeBetweenWinFullscreenModes();
-  vsprintf(pTmpBuf.data(), Format, va);
-  if ( pMouse )
-    pMouse->Activate(0);
-  ClipCursor(0);
-  MessageBoxA(0, pTmpBuf.data(), "Error", 0x30u);
-  Game_DeinitializeAndTerminate(1);
-}
-
 //----- (00466C40) --------------------------------------------------------
 const wchar_t *MENU_STATE_to_string(MENU_STATE m)
 {
--- a/mm7_3.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7_3.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "Weather.h"
 #include "Texture.h"
 #include "mm7_data.h"
@@ -160,14 +158,14 @@
           {
             a3 = stru_721530.field_6C;
             if ( sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
-                   stru_721530.field_58.x, stru_721530.field_58.y, stru_721530.field_58.z, pFace, a10) )
+                   stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
             {
               v17 = a3;
             }
             else
             {
               a3 = stru_721530.field_6C + stru_721530.prolly_normal_d;
-              if ( !sub_475D85(&stru_721530.normal, &stru_721530.field_58, &a3, pFace) )
+              if ( !sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, pFace) )
                 goto LABEL_34;
               v17 = a3 - stru_721530.prolly_normal_d;
               a3 -= stru_721530.prolly_normal_d;
@@ -187,8 +185,8 @@
         || (v19 = pFace->pFacePlane_old.vNormal.x,
             v20 = pFace->pFacePlane_old.vNormal.y,
             v30 = v19,
-            v21 = (stru_721530.field_34.x * v19 + pFace->pFacePlane_old.dist + stru_721530.field_34.y * v20
-                 + stru_721530.field_34.z * pFace->pFacePlane_old.vNormal.z) >> 16,
+            v21 = (stru_721530.position.x * v19 + pFace->pFacePlane_old.dist + stru_721530.position.y * v20
+                 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16,
             v21 <= 0)
         || (v22 = (stru_721530.field_4C * v30 + pFace->pFacePlane_old.dist + stru_721530.field_50 * v20
                  + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16,
@@ -197,14 +195,14 @@
         || v22 > v21 )
         goto LABEL_45;
       a3 = stru_721530.field_6C;
-      if ( sub_47531C(stru_721530.field_8, &a3, stru_721530.field_34.x, stru_721530.field_34.y, stru_721530.field_34.z,
-             stru_721530.field_58.x, stru_721530.field_58.y, stru_721530.field_58.z, pFace, a10) )
+      if ( sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
+             stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
       {
         v23 = a3;
         goto LABEL_43;
       }
-      a3 = stru_721530.field_6C + stru_721530.field_8;
-      if ( sub_475D85(&stru_721530.field_34, &stru_721530.field_58, &a3, pFace) )
+      a3 = stru_721530.field_6C + stru_721530.field_8_radius;
+      if ( sub_475D85(&stru_721530.position, &stru_721530.direction, &a3, pFace) )
       {
         v23 = a3 - stru_721530.prolly_normal_d;
         a3 -= stru_721530.prolly_normal_d;
@@ -373,9 +371,9 @@
                  stru_721530.normal.x,
                  stru_721530.normal.y,
                  stru_721530.normal.z,
-                 stru_721530.field_58.x,
-                 stru_721530.field_58.y,
-                 stru_721530.field_58.z,
+                 stru_721530.direction.x,
+                 stru_721530.direction.y,
+                 stru_721530.direction.z,
                  &f,
                  a10,
                  a11) )
@@ -384,8 +382,8 @@
           }
           else
           {
-            v11 = stru_721530.field_58.y;
-            v12 = stru_721530.field_58.z;
+            v11 = stru_721530.direction.y;
+            v12 = stru_721530.direction.z;
             v13 = stru_721530.normal.y;
             a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
             if ( !sub_475F30(
@@ -394,7 +392,7 @@
                     stru_721530.normal.x,
                     v13,
                     stru_721530.normal.z,
-                    stru_721530.field_58.x,
+                    stru_721530.direction.x,
                     v11,
                     v12,
                     a10) )
@@ -415,10 +413,10 @@
 LABEL_29:
     if ( stru_721530.field_0 & 1 )
     {
-      v15 = (f.pFacePlane_old.vNormal.z * stru_721530.field_34.z
+      v15 = (f.pFacePlane_old.vNormal.z * stru_721530.position.z
            + f.pFacePlane_old.dist
-           + f.pFacePlane_old.vNormal.y * stru_721530.field_34.y
-           + f.pFacePlane_old.vNormal.x * stru_721530.field_34.x) >> 16;
+           + f.pFacePlane_old.vNormal.y * stru_721530.position.y
+           + f.pFacePlane_old.vNormal.x * stru_721530.position.x) >> 16;
       if ( v15 > 0 )
       {
         v16 = (f.pFacePlane_old.vNormal.z * stru_721530.field_54
@@ -430,15 +428,14 @@
           if ( v16 <= v15 )
           {
             a2 = stru_721530.field_6C;
-            if ( sub_4754BF(
-                   stru_721530.field_8,
+            if ( sub_4754BF(stru_721530.field_8_radius,
                    &a2,
-                   stru_721530.field_34.x,
-                   stru_721530.field_34.y,
-                   stru_721530.field_34.z,
-                   stru_721530.field_58.x,
-                   stru_721530.field_58.y,
-                   stru_721530.field_58.z,
+                   stru_721530.position.x,
+                   stru_721530.position.y,
+                   stru_721530.position.z,
+                   stru_721530.direction.x,
+                   stru_721530.direction.y,
+                   stru_721530.direction.z,
                    &f,
                    a10,
                    a11) )
@@ -453,17 +450,16 @@
             }
             else
             {
-              v18 = stru_721530.field_58.y;
-              v19 = stru_721530.field_58.z;
-              v20 = stru_721530.field_34.y;
-              a2 = stru_721530.field_6C + stru_721530.field_8;
-              if ( sub_475F30(
-                     &a2,
+              v18 = stru_721530.direction.y;
+              v19 = stru_721530.direction.z;
+              v20 = stru_721530.position.y;
+              a2 = stru_721530.field_6C + stru_721530.field_8_radius;
+              if ( sub_475F30(&a2,
                      &f,
-                     stru_721530.field_34.x,
+                     stru_721530.position.x,
                      v20,
-                     stru_721530.field_34.z,
-                     stru_721530.field_58.x,
+                     stru_721530.position.z,
+                     stru_721530.direction.x,
                      v18,
                      v19,
                      a10) )
@@ -564,15 +560,15 @@
                     {
                       v8 = v4 - stru_721530.normal.x;
                       v9 = v5 - stru_721530.normal.y;
-                      if ( abs(((v4 - stru_721530.normal.x) * stru_721530.field_58.y
-                              - (v5 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16) <= v3
+                      if ( abs(((v4 - stru_721530.normal.x) * stru_721530.direction.y
+                              - (v5 - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= v3
                                                                                               + stru_721530.prolly_normal_d )
                       {
-                        v10 = (v8 * stru_721530.field_58.x + v9 * stru_721530.field_58.y) >> 16;
+                        v10 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16;
                         if ( v10 > 0 )
                         {
                           v11 = stru_721530.normal.z
-                              + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v10) >> 16);
+                              + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
                           if ( v11 >= *(int *)(v14 + 10) - stru_721530.prolly_normal_d )
                           {
                             if ( v11 <= v13 + stru_721530.prolly_normal_d + *(int *)(v14 + 10) )
@@ -600,7 +596,7 @@
 }
 
 //----- (0046EF01) --------------------------------------------------------
-int  _46EF01_collision_chech_player(int a1)
+int _46EF01_collision_chech_player(int a1)
 {
   int v1; // edx@1
   int result; // eax@1
@@ -615,10 +611,10 @@
   int v11; // [sp+18h] [bp-4h]@7
 
   v8 = a1;
-  v1 = 2 * pParty->field_14;
+  v1 = 2 * pParty->field_14_radius;
   result = pParty->vPosition.x;
   v9 = pParty->uPartyHeight;
-  if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14 )
+  if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14_radius )
   {
     if ( stru_721530.sMinX >= pParty->vPosition.x - v1 )
     {
@@ -632,18 +628,18 @@
             {
               v3 = stru_721530.prolly_normal_d + v1;
               v11 = pParty->vPosition.x - stru_721530.normal.x;
-              v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
-                  - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
+              v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
+                  - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
               v10 = pParty->vPosition.y - stru_721530.normal.y;
-              result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
-                          - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16);
+              result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
+                          - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
               if ( result <= v3 )
               {
-                result = v10 * stru_721530.field_58.y;
-                v5 = (v10 * stru_721530.field_58.y + v11 * stru_721530.field_58.x) >> 16;
+                result = v10 * stru_721530.direction.y;
+                v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
                 if ( v5 > 0 )
                 {
-                  v6 = ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
+                  v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
                   result = pParty->vPosition.z;
                   if ( v6 >= pParty->vPosition.z )
                   {
@@ -710,17 +706,15 @@
             && stru_721530.sMaxZ <= v3->pBounding.z2
             && stru_721530.sMinZ >= v3->pBounding.z1 )
           {
-            v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x
-                + v3->pFacePlane_old.dist
+            v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x + v3->pFacePlane_old.dist
                 + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y
                 + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16;
-            v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z
-                + v3->pFacePlane_old.dist
+            v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z + v3->pFacePlane_old.dist
                 + stru_721530.normal2.x * v3->pFacePlane_old.vNormal.x
                 + stru_721530.normal2.y * v3->pFacePlane_old.vNormal.y) >> 16;
             if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
               && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
-              && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.field_58, &a3, v3))
+              && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, v3))
               && a3 < (signed int)v10 )
             {
               v0 = v9;
@@ -758,13 +752,13 @@
 }
 
 //----- (0047050A) --------------------------------------------------------
-int stru141::_47050A(int a2)
+int stru141_actor_collision_object::_47050A(int dt)
 {
-  stru141 *v2; // esi@1
-  signed int v3; // eax@1
-  int v4; // ecx@1
-  int v5; // edx@1
-  int v6; // edx@1
+  stru141_actor_collision_object *v2; // esi@1
+  //signed int v3; // eax@1
+  //int v4; // ecx@1
+  //int v5; // edx@1
+  //int v6; // edx@1
   int v7; // eax@1
   int v8; // eax@3
   signed int result; // eax@4
@@ -789,34 +783,36 @@
   int v28; // [sp+14h] [bp+8h]@5
 
   v2 = this;
-  v3 = integer_sqrt(this->field_24 * this->field_24 + this->field_20 * this->field_20 + this->field_1C * this->field_1C);
-  v4 = v3 | 1;
-  v5 = v2->field_1C;
-  v2->field_64 = v3 | 1;
-  v2->field_58.x = 65536 / (v3 | 1) * v5;
-  v2->field_58.y = 65536 / (v3 | 1) * v2->field_20;
-  v6 = 65536 / (v3 | 1) * v2->field_24;
-  v2->field_68 = 65536 / (v3 | 1);
-  v7 = a2;
-  v2->field_58.z = v6;
-  if ( !a2 )
+  int speed = 1 | integer_sqrt(this->velocity.z * this->velocity.z + this->velocity.y * this->velocity.y + this->velocity.x * this->velocity.x);
+
+  v2->direction.x = 65536 / speed * v2->velocity.x;
+  v2->direction.y = 65536 / speed * v2->velocity.y;
+  v2->direction.z = 65536 / speed * v2->velocity.z;
+
+  v2->speed = speed;
+  v2->inv_speed = 65536 / speed;
+
+  if (dt)
+    v7 = dt;
+  else
     v7 = pEventTimer->dt_in_some_format;
-  v8 = ((unsigned __int64)(v7 * (signed __int64)v4) >> 16) - v2->field_70;
+
+  v8 = fixpoint_sub0(v7, speed) - v2->field_70; // speed * dt - something
   v2->field_6C = v8;
   if ( v8 > 0 )
   {
-    v10 = ((unsigned __int64)(v8 * (signed __int64)v2->field_58.x) >> 16) + v2->normal.x;
+    v10 = fixpoint_sub0(v8, v2->direction.x) + v2->normal.x;
     v2->field_4C = v10;
     v2->normal2.x = v10;
-    v11 = ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.y) >> 16) + v2->normal.y;
+    v11 = fixpoint_sub0(v2->field_6C, v2->direction.y) + v2->normal.y;
     v2->field_50 = v11;
     v2->normal2.y = v11;
-    v2->normal2.z = ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.z) >> 16) + v2->normal.z;
-    v12 = v2->field_34.z;
+    v2->normal2.z = fixpoint_sub0(v2->field_6C, v2->direction.z) + v2->normal.z;
+    v12 = v2->position.z;
     v13 = v2->normal.x;
     v14 = v2->normal2.x;
     v15 = v2->prolly_normal_d;
-    v16 = v12 + ((unsigned __int64)(v2->field_6C * (signed __int64)v2->field_58.z) >> 16);
+    v16 = v12 + fixpoint_sub0(v2->field_6C, v2->direction.z);
     v28 = v16;
     v2->field_54 = v16;
     v17 = v13;
@@ -844,7 +840,7 @@
     else
       v25 = v24 - v15;
     v2->sMaxZ = v25;
-    v26 = v2->field_8;
+    v26 = v2->field_8_radius;
     if ( v12 <= v28 )
       v27 = v28 + v26;
     else
@@ -864,7 +860,7 @@
 }
 
 //----- (004706C6) --------------------------------------------------------
-void  UpdateActors_ODM()
+void UpdateActors_ODM()
 {
   Actor *v0; // esi@2
   AIState uAIState; // ax@2
@@ -878,22 +874,22 @@
   //unsigned __int8 v9; // zf@17
   unsigned __int8 v10; // sf@17
   unsigned __int16 v11; // ax@21
-  int v12; // eax@29
-  unsigned __int64 v13; // qax@29
-  int v14; // eax@30
-  unsigned __int64 v15; // qax@30
+  //int v12; // eax@29
+  //unsigned __int64 v13; // qax@29
+  //int v14; // eax@30
+  //unsigned __int64 v15; // qax@30
   int v16; // eax@33
   //int v17; // edi@34
-  int v18; // edx@42
-  int v19; // ecx@42
+  //int v18; // edx@42
+  //int v19; // ecx@42
   __int16 v20; // ax@42
-  int v21; // ebx@42
-  int v22; // edi@42
-  int v23; // ecx@42
-  __int16 v24; // ax@42
+  //int v21; // ebx@42
+  //int v22; // edi@42
+  //int v23; // ecx@42
+  //__int16 v24; // ax@42
   int v25; // eax@45
   signed int v26; // ecx@50
-  int v27; // eax@52
+  //int v27; // eax@52
   int v28; // eax@54
   signed int v29; // ebx@57
   signed int v30; // eax@57
@@ -916,8 +912,8 @@
   signed int v47; // ebx@85
   int v48; // edi@85
   int v49; // edi@85
-  int v50; // eax@85
-  unsigned __int64 v51; // qax@85
+  //int v50; // eax@85
+  //unsigned __int64 v51; // qax@85
   //unsigned __int8 v52; // zf@87
   //unsigned __int8 v53; // sf@87
  // unsigned __int8 v54; // of@104
@@ -940,12 +936,12 @@
   int v71; // [sp+38h] [bp-18h]@62
   int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10
   int v72b;
-  int v73; // [sp+40h] [bp-10h]@17
+  //int v73; // [sp+40h] [bp-10h]@17
   int uIsFlying; // [sp+44h] [bp-Ch]@8
   unsigned int v75; // [sp+48h] [bp-8h]@1
   int uIsOnWater; // [sp+4Ch] [bp-4h]@10
 
-  for(v75=0;(signed int)v75 < (signed int)uNumActors;++v75)
+  for (v75 = 0; v75 < uNumActors; ++v75)
   {
     v0 = &pActors[v75];
     v66 = v0->vPosition.x;
@@ -985,53 +981,34 @@
     if ( v0->uCurrentActionAnimation == ANIM_Walking )
     {
       v8 = v0->uMovementSpeed;
-      v73 = v0->uMovementSpeed;
       if ( (signed __int64)v0->pActorBuffs[7].uExpireTime > 0 )
       {
-        v8 = (signed __int64)((double)v73 * 0.5);
-        v73 = (signed __int64)((double)v73 * 0.5);
+        v8 = (signed __int64)((double)v8 * 0.5);
       }
       if ( uAIState == Fleeing || uAIState == Pursuing )
       {
         v8 *= 2;
-        v73 = v8;
       }
       if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 )
-        v8 = (signed __int64)((double)v73 * flt_6BE3AC_debug_recmod1_x_1_6);
+        v8 *= flt_6BE3AC_debug_recmod1_x_1_6;
       if ( v8 > 1000 )
         v8 = 1000;
-      v12 = stru_5C6E00->Cos(v0->uYawAngle);
-      v13 = v12 * (signed __int64)v8;
-      v73 = v13 >> 16;
-      v0->vVelocity.x = WORD1(v13);
-      v69 = stru_5C6E00->Sin(v0->uYawAngle);
-      v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v8) >> 16;
-      v0->vVelocity.y = v69 * v8 >> 16;
+
+      v0->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v0->uYawAngle), v8);
+      v0->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v0->uYawAngle), v8);
       if ( uIsFlying )
       {
-        v14 = stru_5C6E00->Sin(v0->uPitchAngle);
-        v69 = v14;
-        v15 = v14 * (signed __int64)v8;
-        v73 = v15 >> 16;
-        v0->vVelocity.z = WORD1(v15);
+        v0->vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(v0->uPitchAngle), v8);
       }
       //v7 = v68;
     }
     else
     {
-      v73 = v0->vVelocity.x;
-      v69 = 55000;
-      v73 = (unsigned __int64)(55000i64 * v73) >> 16;
-      v0->vVelocity.x = v73;
-      v73 = v0->vVelocity.y;
-      v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v73) >> 16;
-      v0->vVelocity.y = v73;
+      v0->vVelocity.x = fixpoint_sub0(55000, v0->vVelocity.x);
+      v0->vVelocity.y = fixpoint_sub0(55000, v0->vVelocity.y);
       if ( uIsFlying )
       {
-        v69 = 55000;
-        v73 = v0->vVelocity.z;
-        v73 = (unsigned __int64)(55000i64 * v73) >> 16;
-        v0->vVelocity.z = v73;
+        v0->vVelocity.z = fixpoint_sub0(55000, v0->vVelocity.z);
       }
     }
     if ( v0->vPosition.z < v5 )
@@ -1045,24 +1022,18 @@
     {
       if ( v70 && !uIsAboveFloor && v67 )
       {
-        v18 = v0->vPosition.y;
-        v19 = v0->vPosition.x;
         v0->vPosition.z = v5;
-        ODM_GetTerrainNormalAt(v19, v18, &v62);
+        ODM_GetTerrainNormalAt(v0->vPosition.x, v0->vPosition.y, &v62);
         v20 = GetGravityStrength();
-        v21 = v62.y;
-        v22 = v62.z;
-        v23 = v62.y * v0->vVelocity.y;
+        //v21 = v62.y;
+        //v22 = v62.z;
+        //v23 = v62.y * v0->vVelocity.y;
         v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
-        v73 = abs(v62.x * v0->vVelocity.x + v22 * v0->vVelocity.z + v23) >> 16;
-        v72b = v21;
-        v0->vVelocity.x += (unsigned int)(v73 * v62.x) >> 16;
-        v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16;
-        v24 = v72b;
-        v72b = v22;
-        v0->vVelocity.y += v24;
-        v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16;
-        v0->vVelocity.z += v72b;
+        int v73 = abs(v62.x * v0->vVelocity.x + v62.z * v0->vVelocity.z + v62.y * v0->vVelocity.y) >> 16;
+        //v72b = v21;
+        v0->vVelocity.x += fixpoint_sub0(v73, v62.x);
+        v0->vVelocity.y += fixpoint_sub0(v73, v62.y);
+        v0->vVelocity.z += fixpoint_sub0(v73, v62.z);
         //v17 = 0;
       }
     }
@@ -1090,28 +1061,28 @@
       v26 = 40;
     else
       v26 = v0->uActorRadius;
-    v27 = v0->uActorHeight;
+
     stru_721530.field_84 = -1;
-    stru_721530.field_8 = v26;
+    stru_721530.field_8_radius = v26;
     stru_721530.prolly_normal_d = v26;
-    stru_721530.field_C = v27;
+    stru_721530.height = v0->uActorHeight;
     stru_721530.field_70 = 0;
     v69 = 0;
     while ( 1 )
     {
-      stru_721530.field_34.x = v0->vPosition.x;
-      stru_721530.normal.x = stru_721530.field_34.x;
-      stru_721530.field_34.y = v0->vPosition.y;
-      stru_721530.normal.y = stru_721530.field_34.y;
+      stru_721530.position.x = v0->vPosition.x;
+      stru_721530.normal.x = stru_721530.position.x;
+      stru_721530.position.y = v0->vPosition.y;
+      stru_721530.normal.y = stru_721530.position.y;
       v28 = v0->vPosition.z;
       stru_721530.normal.z = v28 + v26 + 1;
-      stru_721530.field_34.z = v28 - v26 + stru_721530.field_C - 1;
-      if ( stru_721530.field_34.z < stru_721530.normal.z )
-        stru_721530.field_34.z = v28 + v26 + 1;
-      stru_721530.field_1C = v0->vVelocity.x;
+      stru_721530.position.z = v28 - v26 + stru_721530.height - 1;
+      if ( stru_721530.position.z < stru_721530.normal.z )
+        stru_721530.position.z = v28 + v26 + 1;
+      stru_721530.velocity.x = v0->vVelocity.x;
       stru_721530.uSectorID = 0;
-      stru_721530.field_20 = v0->vVelocity.y;
-      stru_721530.field_24 = v0->vVelocity.z;
+      stru_721530.velocity.y = v0->vVelocity.y;
+      stru_721530.velocity.z = v0->vVelocity.z;
       if ( stru_721530._47050A(0) )
         break;
       _46E889_collide_against_bmodels(1u);
@@ -1129,11 +1100,10 @@
       }
       v71 = i > 1;
       if ( stru_721530.field_7C < stru_721530.field_6C )
-        v70 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
+        v70 = fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z);
       //v34 = 0;
       v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
-      v36 = ODM_GetFloorLevel(
-              stru_721530.normal2.x,
+      v36 = ODM_GetFloorLevel(stru_721530.normal2.x,
               stru_721530.normal2.y,
               stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
               v0->uActorHeight,
@@ -1163,13 +1133,13 @@
         v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
         break;
       }
-      v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-      v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16;
-      v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-      v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16;
-      v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
+      //v72b = fixpoint_sub0(stru_721530.field_7C, stru_721530.field_58.x);
+      v0->vPosition.x += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x);
+      //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
+      v0->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y);
+      //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
+      v0->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z);
       v38 = stru_721530.uFaceID;
-      v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
       stru_721530.field_70 += stru_721530.field_7C;
 	  v39 = PID_ID(v38);
       switch ( PID_TYPE(v38) )
@@ -1190,7 +1160,7 @@
 				  Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
 			  }
             }
-            else if ( v71 != 0 )
+            else if ( v71 )
 			{
               Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
 			}
@@ -1225,20 +1195,14 @@
           v48 = stru_5C6E00->Atan2(
                   v0->vPosition.x - pLevelDecorations[v39].vPosition.x,
                   v0->vPosition.y - pLevelDecorations[v39].vPosition.y);
-          v71 = stru_5C6E00->Cos(v48);
-          v70 = (unsigned __int64)(v71 * (signed __int64)v47) >> 16;
           v49 = v48;
-          v0->vVelocity.x = (unsigned int)(v71 * v47) >> 16;
-          v50 = stru_5C6E00->Sin(v48);
-          v71 = v50;
-          v51 = v50 * (signed __int64)v47;
-          v70 = v51 >> 16;
-          v0->vVelocity.y = WORD1(v51);
+          v0->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v48), v47);
+          v0->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v48), v47);
           break;
         case OBJECT_BModel:
           v40 = &pOutdoor->pBModels[v38 >> 9];
           v41 = &v40->pFaces[v39 & 0x3F];
-          if ( !(BYTE3(v41->uAttributes) & 0x20) )
+          if ( !(v41->uAttributes & 0x20000000) )
           {
             v42 = v41->uPolygonType;
             if ( v42 == 3 )
@@ -1257,17 +1221,12 @@
             {
               v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z
                                                                     + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16;
-              if ( stru_721530.field_64 >> 3 > v72b )
-                v72b = stru_721530.field_64 >> 3;
-              v73 = v41->pFacePlane.vNormal.x;
-              v73 = (unsigned __int64)(v72b * (signed __int64)v73) >> 16;
-              v71 = v41->pFacePlane.vNormal.y;
-              v71 = (unsigned __int64)(v72b * (signed __int64)v71) >> 16;
-              v70 = v41->pFacePlane.vNormal.z;
-              v70 = (unsigned __int64)(v72b * (signed __int64)(signed int)v70) >> 16;
-              v0->vVelocity.x += v73;
-              v0->vVelocity.y += v71;
-              v0->vVelocity.z += v70;
+              if ( (stru_721530.speed >> 3) > v72b )
+                v72b = stru_721530.speed >> 3;
+
+              v0->vVelocity.x += fixpoint_sub0(v72b, v41->pFacePlane.vNormal.x);
+              v0->vVelocity.y += fixpoint_sub0(v72b, v41->pFacePlane.vNormal.y);
+              v0->vVelocity.z += fixpoint_sub0(v72b, v41->pFacePlane.vNormal.z);
               if ( v42 != 4 )
               {
                 v45 = v0->vPosition.z;
@@ -1288,20 +1247,12 @@
           }
           break;
       }
-      v70 = v0->vVelocity.x;
-      v71 = 58500;
-      v70 = (unsigned __int64)(58500i64 * (signed int)v70) >> 16;
-      v0->vVelocity.x = v70;
-      v70 = v0->vVelocity.y;
-      v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16;
-      v71 = 58500;
-      v0->vVelocity.y = v70;
-      v70 = v0->vVelocity.z;
-      v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16;
+
+      v0->vVelocity.x = fixpoint_sub0(58500, v0->vVelocity.x);
+      v0->vVelocity.y = fixpoint_sub0(58500, v0->vVelocity.y);
+      v0->vVelocity.z = fixpoint_sub0(58500, v0->vVelocity.z);
+
       ++v69;
-      //v54 = v69 < 100;
-      //v10 = (v69 - 100) < 0;
-      v0->vVelocity.z = v70;
       if ( v69 >= 100 )
         break;
       v26 = stru_721530.prolly_normal_d;
@@ -1368,8 +1319,8 @@
     //do
     //{
       //LOWORD(v0) = item->uAttributes;
-    if (item->uAttributes & 0x40)
-      item->uAttributes &= 0xFFBF;
+    if (item->uAttributes & OBJECT_40)
+      item->uAttributes &= ~OBJECT_40;
     else
     {
               //v3 = item->uObjectDescID;
@@ -1748,37 +1699,37 @@
         break;
 
       case PARTY_StrafeLeft:
-        v2 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16;
-        v1 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16;
+        v2 -= fixpoint_sub0(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2);
+        v1 += fixpoint_sub0(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2);
         v78 = 1;
         break;
       case PARTY_StrafeRight:
-        v2 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16;
-        v1 -= (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16;
+        v2 += fixpoint_sub0(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2);
+        v1 -= fixpoint_sub0(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2);
         v78 = 1;
         break;
       case PARTY_WalkForward:
-        v2 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)(5 * (double)v81 * fWalkSpeedMultiplier)) >> 16;
-        v1 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)(5 * (double)v81 * fWalkSpeedMultiplier)) >> 16;
+        v2 += fixpoint_sub0(stru_5C6E00->Cos(angle), 5 * v81 * fWalkSpeedMultiplier);
+        v1 += fixpoint_sub0(stru_5C6E00->Sin(angle), 5 * v81 * fWalkSpeedMultiplier);
         v78 = 1;
         break;
       case PARTY_WalkBackward:
-        v2 -= (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16;
-        v1 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16;
+        v2 -= fixpoint_sub0(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier);
+        v1 -= fixpoint_sub0(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier);
         v78 = 1;
         break;
       case PARTY_RunForward:
-        v2 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16;
-        v1 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16;
+        v2 += fixpoint_sub0(stru_5C6E00->Cos(angle), 2 * v81 * fWalkSpeedMultiplier);
+        v1 += fixpoint_sub0(stru_5C6E00->Sin(angle), 2 * v81 * fWalkSpeedMultiplier);
         v72 = 1;
         break;
       case PARTY_RunBackward:
         //v32 = stru_5C6E00->SinCos(angle);
         //v33 = (double)v81;
         //v88 = (double)v81;
-        v2 -= (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16;
+        v2 -= fixpoint_sub0(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier);
         //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
-        v1 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16;
+        v1 -= fixpoint_sub0(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier);
         v72 = 1;
         break;
       case PARTY_LookUp:
@@ -1855,23 +1806,23 @@
   }
   stru_721530.field_84 = -1;
   stru_721530.field_70 = 0;
-  stru_721530.prolly_normal_d = pParty->field_14;
-  stru_721530.field_8 = pParty->field_14 >> 1;
+  stru_721530.prolly_normal_d = pParty->field_14_radius;
+  stru_721530.field_8_radius = pParty->field_14_radius / 2;
   auto v83 = 0;
   stru_721530.field_0 = 1;
-  stru_721530.field_C = pParty->uPartyHeight - 32;
+  stru_721530.height = pParty->uPartyHeight - 32;
   while ( 1 )
   {
     new_party_z = party_z;
-    stru_721530.field_34.x = new_party_x;
+    stru_721530.position.x = new_party_x;
     stru_721530.normal.x = new_party_x;
-    stru_721530.field_1C = v2;
-    stru_721530.field_34.y = new_party_y;
+    stru_721530.velocity.x = v2;
+    stru_721530.position.y = new_party_y;
     stru_721530.normal.y = new_party_y;
-    stru_721530.field_20 = v1;
+    stru_721530.velocity.y = v1;
     stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1;
-    stru_721530.field_34.z = stru_721530.field_C + party_z + 1;
-    stru_721530.field_24 = pParty->uFallSpeed;
+    stru_721530.position.z = stru_721530.height + party_z + 1;
+    stru_721530.velocity.z = pParty->uFallSpeed;
     stru_721530.uSectorID = uSectorID;
     v38 = 0;
     if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
@@ -1898,9 +1849,9 @@
     }
     else
     {
-      v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16) + new_party_x;
-      uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
-      v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
+      v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16) + new_party_x;
+      uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16);
+      v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16);
     }
     v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID);
     if ( v42 == -30000 || v42 - new_party_z > 128 )
@@ -1912,12 +1863,12 @@
       new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
       break;
     }
-    new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-    new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
+    new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
+    new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16;
     v43 = stru_721530.uFaceID;
     uSectorID = stru_721530.uSectorID;
     stru_721530.field_70 += stru_721530.field_7C;
-    auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z;
+    auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16) + new_party_z;
     if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
     {
       if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0
@@ -1964,8 +1915,8 @@
 			if ( !v47 )
 			{
 			  v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-			  if ( stru_721530.field_64 >> 3 > v80 )
-				v80 = stru_721530.field_64 >> 3;
+			  if ((stru_721530.speed >> 3) > v80 )
+				v80 = stru_721530.speed >> 3;
 			  v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
 			  v81 = v44->pFacePlane_old.vNormal.y;
 			  v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
@@ -1992,8 +1943,8 @@
 			else
 			{
 				v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-				if ( stru_721530.field_64 >> 3 > v80 )
-				  v80 = stru_721530.field_64 >> 3;
+				if ((stru_721530.speed >> 3) > v80 )
+				  v80 = stru_721530.speed >> 3;
 				v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
 				v81 = v44->pFacePlane_old.vNormal.y;
 				v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
@@ -2708,22 +2659,22 @@
   }
   stru_721530.field_84 = -1;
   stru_721530.field_70 = 0;
-  stru_721530.prolly_normal_d = pParty->field_14;
-  stru_721530.field_8 = pParty->field_14 >> 1;
+  stru_721530.prolly_normal_d = pParty->field_14_radius;
+  stru_721530.field_8_radius = pParty->field_14_radius >> 1;
   v126 = 0;
   stru_721530.field_0 = 1;
-  stru_721530.field_C = pParty->uPartyHeight - 32;
+  stru_721530.height = pParty->uPartyHeight - 32;
   do
   {
-    stru_721530.field_34.x = pX;
+    stru_721530.position.x = pX;
     stru_721530.normal.x = pX;
-    stru_721530.field_1C = v2;
-    stru_721530.field_34.y = pY;
+    stru_721530.velocity.x = v2;
+    stru_721530.position.y = pY;
     stru_721530.normal.y = pY;
     stru_721530.normal.z = stru_721530.prolly_normal_d + pZ + 1;
-    stru_721530.field_34.z = stru_721530.field_C + pZ + 1;
-    stru_721530.field_20 = v128;
-    stru_721530.field_24 = pParty->uFallSpeed;
+    stru_721530.position.z = stru_721530.height + pZ + 1;
+    stru_721530.velocity.y = v128;
+    stru_721530.velocity.z = pParty->uFallSpeed;
     v36 = 0;
     stru_721530.uSectorID = 0;
     if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
@@ -2745,10 +2696,10 @@
     }
     else
     {
-      _angle_x = pX + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
-      _angle_y = pY + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
-      pModel = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
-      v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ;
+      _angle_x = pX + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x);
+      _angle_y = pY + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y);
+      pModel = (BSPModel *)fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z);
+      v40 = fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z) + pZ;
     }
     v122 = v40;
     ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
@@ -2884,8 +2835,8 @@
         if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// óï¸ðñÿ â ñòîëá
         {
           v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
-          if ( stru_721530.field_64 >> 3 > v118 )
-            v118 = stru_721530.field_64 >> 3;
+          if ((stru_721530.speed >> 3) > v118 )
+            v118 = stru_721530.speed >> 3;
           v129 = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16;
           _walk_speed = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16;
           v54 = 0;
@@ -2926,8 +2877,8 @@
 			continue;
         }
         v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
-        if ( stru_721530.field_64 >> 3 > v118 )
-          v118 = stru_721530.field_64 >> 3;
+        if ((stru_721530.speed >> 3) > v118 )
+          v118 = stru_721530.speed >> 3;
         v122 = pODMFace->pFacePlane.vNormal.x;
         v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16;
         pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.y;
@@ -4856,7 +4807,7 @@
   v7 = v3;
   v8 = ptr_38;
   sTextureDeltaV = v2->sTextureDeltaV;
-  v8->_48616B(v4, v7, 0, 0, v5, v6);
+  v8->_48616B_frustum_odm(v4, v7, 0, 0, v5, v6);
   return 1;
 }
 
@@ -5377,7 +5328,7 @@
        (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z);//61 / 184 / 310 èçìåíÿåòñÿ ïðè íàêëîíå êàìåðû
 
   pSkyPolygon.Create_48607B(&stru_8019C8);
-  pSkyPolygon.ptr_38->Inverse_sky_48694B();//maybe creating skydome(âîçìîæíî ñîçäàíèå êóïîëà íåáà)
+  pSkyPolygon.ptr_38->_48694B_frustum_sky();//maybe creating skydome(âîçìîæíî ñîçäàíèå êóïîëà íåáà)
   pSkyPolygon.uTileBitmapID = pOutdoor->uSky_TextureID;//íîìåð òåêñòóðû
   pSkyPolygon.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);//òåêñòóðà íåáà
   if (pOutdoor->uSky_TextureID == -1)
@@ -5940,23 +5891,10 @@
 }
 
 
-//----- (00481EB7) --------------------------------------------------------
-void ResetPolygons()
-{
-  for (auto i = 0; i < pOutdoorCamera->uNumPolygons; ++i)
-  {
-    array_77EC08[i].prolly_head = nullptr;
-    array_77EC08[i].prolly_tail = nullptr;
-
-    array_77EC08[i].flags = 0;
-    array_77EC08[i].field_32 = 0;
-  }
-}
-
 //----- (00481ED9) --------------------------------------------------------
 void  sub_481ED9_MessWithOutdoorCamera()
 {
-  stru_8019C8._48616B(65536, 0, 0, 0, 65536, 0);
+  stru_8019C8._48616B_frustum_odm(65536, 0, 0, 0, 65536, 0);
   pOutdoorCamera->uNumPolygons = 0;
   pOutdoorCamera->uNumEdges = 0;
   pOutdoorCamera->uNumSpans = 0;
@@ -6027,7 +5965,7 @@
 
   int y_min = min(y1, min(y2, y3)),
       y_max = max(y1, max(y2, y3));
-  return y_max - y_min > 512;
+  return (y_max - y_min) > 512;
 
   /*if ( y1 >= y2 )
   {
@@ -6179,126 +6117,109 @@
 }
 
 //----- (0048616B) --------------------------------------------------------
-int stru149::_48616B(int a2, int a3, int a4, int a5, int a6, int a7)
+void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7)
 {
   int v7; // ebx@1
-  int v8; // esi@1
+  //int v8; // esi@1
   int v9; // edi@1
-  int v10; // eax@1
+  //int v10; // eax@1
   int v11; // edx@1
-  int v12; // esi@2
-  int v13; // eax@2
-  int v14; // ST10_4@3
-  int v15; // esi@3
-  int v16; // eax@5
+  //int v12; // esi@2
+  //int v13; // eax@2
+  //int v14; // ST10_4@3
+  //int v15; // esi@3
+  //int v16; // eax@5
   int v17; // ST0C_4@6
-  int v18; // eax@8
+  //int v18; // eax@8
   int v19; // ST0C_4@9
-  int v20; // eax@10
-  int v21; // edx@10
-  int v22; // eax@10
-  int result; // eax@10
+  //int v20; // eax@10
+  //int v21; // edx@10
+  //int v22; // eax@10
+  //int result; // eax@10
   int v24; // [sp+14h] [bp-14h]@1
   int v25; // [sp+18h] [bp-10h]@1
-  int v26; // [sp+1Ch] [bp-Ch]@1
+  //int v26; // [sp+1Ch] [bp-Ch]@1
   int v27; // [sp+24h] [bp-4h]@1
-  int v28; // [sp+30h] [bp+8h]@10
-  int v29; // [sp+3Ch] [bp+14h]@10
+  //int v28; // [sp+30h] [bp+8h]@10
+  //int v29; // [sp+3Ch] [bp+14h]@10
 
   v25 = pOutdoorCamera->camera_rotation_x_int_cosine;
   v7 = pOutdoorCamera->camera_rotation_y_int_sine;
   v27 = pOutdoorCamera->camera_rotation_x_int_sine;
-  v8 = -pIndoorCamera->pos.y;
+  //v8 = -pIndoorCamera->pos.y;
   v9 = pOutdoorCamera->camera_rotation_y_int_cosine;
-  v26 = -pIndoorCamera->pos.z;
-  v24 = -pIndoorCamera->pos.x;
-  v10 = pOutdoorCamera->camera_rotation_y_int_cosine * -pIndoorCamera->pos.x;
-  v11 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y;
+  //v26 = -pIndoorCamera->pos.z;
+  v11 = pOutdoorCamera->camera_rotation_y_int_cosine * -pIndoorCamera->pos.x + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y;
+  v24 = pOutdoorCamera->camera_rotation_y_int_cosine * -pIndoorCamera->pos.y - pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.x;
   if ( pIndoorCamera->sRotationX )
   {
-    v14 = v10 + pOutdoorCamera->camera_rotation_y_int_sine * -pIndoorCamera->pos.y;
-    v15 = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
-    this->field_0_party_dir_x = ((unsigned __int64)(v11 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16)
-                  + ((unsigned __int64)(-65536
-                                      * pIndoorCamera->pos.z
-                                      * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16);
-    this->field_4_party_dir_y = v15;
-    v12 = v25;
-    v13 = ((unsigned __int64)((v26 << 16) * (signed __int64)v25) >> 16)
-        - ((unsigned __int64)(v14 * (signed __int64)v27) >> 16);
+    this->field_0_party_dir_x = fixpoint_sub0(v11, pOutdoorCamera->camera_rotation_x_int_cosine) +
+                                fixpoint_sub0((-pIndoorCamera->pos.z) << 16, pOutdoorCamera->camera_rotation_x_int_sine);
+    this->field_4_party_dir_y = v24;
+    this->field_8_party_dir_z = fixpoint_sub0((-pIndoorCamera->pos.z) << 16, v25) - fixpoint_sub0(v11, v27);
   }
   else
   {
-    this->field_4_party_dir_y = pOutdoorCamera->camera_rotation_y_int_cosine * v8 - pOutdoorCamera->camera_rotation_y_int_sine * v24;
-    v12 = v25;
     this->field_0_party_dir_x = v11;
-    v13 = v26 << 16;
-  }
-  this->field_8 = v13;
-  if ( pIndoorCamera->sRotationX )
-  {
-    v17 = ((unsigned __int64)(a2 * (signed __int64)v9) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v7) >> 16);
-    this->field_C = ((unsigned __int64)(v17 * (signed __int64)v12) >> 16)
-                  + ((unsigned __int64)(a4 * (signed __int64)v27) >> 16);
-    this->field_10 = ((unsigned __int64)(a3 * (signed __int64)v9) >> 16)
-                   - ((unsigned __int64)(a2 * (signed __int64)v7) >> 16);
-    v16 = ((unsigned __int64)(a4 * (signed __int64)v12) >> 16) - ((unsigned __int64)(v17 * (signed __int64)v27) >> 16);
+    this->field_4_party_dir_y = v24;
+    this->field_8_party_dir_z = (-pIndoorCamera->pos.z) << 16;
+  }
+
+  if (pIndoorCamera->sRotationX)
+  {
+    v17 = fixpoint_sub0(a2, v9) + fixpoint_sub0(a3, v7);
+
+    this->field_C = fixpoint_sub0(v17, v25) + fixpoint_sub0(a4, v27);
+    this->field_10 = fixpoint_sub0(a3, v9) - fixpoint_sub0(a2, v7);
+    this->field_14 = fixpoint_sub0(a4, v25) - fixpoint_sub0(v17, v27);
   }
   else
   {
-    this->field_C = ((unsigned __int64)(a2 * (signed __int64)v9) >> 16)
-                  + ((unsigned __int64)(a3 * (signed __int64)v7) >> 16);
-    this->field_10 = ((unsigned __int64)(a3 * (signed __int64)v9) >> 16)
-                   - ((unsigned __int64)(a2 * (signed __int64)v7) >> 16);
-    v16 = a4;
-  }
-  this->field_14 = v16;
-  if ( pIndoorCamera->sRotationX )
-  {
-    v19 = ((unsigned __int64)(a5 * (signed __int64)v9) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v7) >> 16);
-    this->field_18 = ((unsigned __int64)(v19 * (signed __int64)v12) >> 16)
-                   + ((unsigned __int64)(a7 * (signed __int64)v27) >> 16);
-    this->field_1C = ((unsigned __int64)(a6 * (signed __int64)v9) >> 16)
-                   - ((unsigned __int64)(a5 * (signed __int64)v7) >> 16);
-    v18 = ((unsigned __int64)(a7 * (signed __int64)v12) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v27) >> 16);
+    this->field_C = fixpoint_sub0(a2, v9) + fixpoint_sub0(a3, v7);
+    this->field_10 = fixpoint_sub0(a3, v9) - fixpoint_sub0(a2, v7);
+    this->field_14 = a4;
+  }
+
+  if (pIndoorCamera->sRotationX)
+  {
+    v19 = fixpoint_sub0(a5, v9) + fixpoint_sub0(a6, v7);
+
+    this->field_18 = fixpoint_sub0(v19, v25) + fixpoint_sub0(a7, v27);
+    this->field_1C = fixpoint_sub0(a6, v9) - fixpoint_sub0(a5, v7);
+    this->field_20 = fixpoint_sub0(a7, v25) - fixpoint_sub0(v19, v27);
   }
   else
   {
-    this->field_18 = ((unsigned __int64)(a5 * (signed __int64)v9) >> 16)
-                   + ((unsigned __int64)(a6 * (signed __int64)v7) >> 16);
-    this->field_1C = ((unsigned __int64)(a6 * (signed __int64)v9) >> 16)
-                   - ((unsigned __int64)(a5 * (signed __int64)v7) >> 16);
-    v18 = a7;
-  }
+    this->field_18 = fixpoint_sub0(a5, v9) + fixpoint_sub0(a6, v7);
+    this->field_1C = fixpoint_sub0(a6, v9) - fixpoint_sub0(a5, v7);
+    this->field_20 = a7;
+  }
+
   this->field_18 = -this->field_18;
   this->field_1C = -this->field_1C;
-  this->field_20 = v18;
-  v20 = this->field_C;
   this->field_20 = -this->field_20;
-  v21 = ((unsigned __int64)(v20 * (signed __int64)this->field_0_party_dir_x) >> 16)
-      + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16)
-      + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
-  v28 = this->field_18;
-  v22 = this->field_0_party_dir_x;
-  this->field_24 = v21;
-  v29 = (unsigned __int64)(v28 * (signed __int64)v22) >> 16;
-  result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16;
-  this->field_28 = v29 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
-  return result;
+
+  this->field_24 = fixpoint_dot(this->field_C,  this->field_0_party_dir_x,
+                                this->field_10, this->field_4_party_dir_y,
+                                this->field_14, this->field_8_party_dir_z);
+  this->field_28 = fixpoint_dot(this->field_18, this->field_0_party_dir_x,
+                                this->field_1C, this->field_4_party_dir_y,
+                                this->field_20, this->field_8_party_dir_z);
 }
 
 //----- (0048694B) --------------------------------------------------------
-void stru149::Inverse_sky_48694B()
+void stru149::_48694B_frustum_sky()
 {
   this->field_18 = -this->field_18;
   this->field_1C = -this->field_1C;
   this->field_20 = -this->field_20;
-  this->field_24 = ((unsigned __int64)(this->field_C * (signed __int64)this->field_0_party_dir_x) >> 16)
-                 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16)
-                 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
-  this->field_28 = ((unsigned __int64)(this->field_18 * (signed __int64)this->field_0_party_dir_x) >> 16)
-                 + ((unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16)
-                 + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
+
+  this->field_24 = fixpoint_dot(this->field_C,  this->field_0_party_dir_x,
+                                this->field_10, this->field_4_party_dir_y,
+                                this->field_14, this->field_8_party_dir_z);
+  this->field_28 = fixpoint_dot(this->field_18, this->field_0_party_dir_x,
+                                this->field_1C, this->field_4_party_dir_y,
+                                this->field_20, this->field_8_party_dir_z);
 }
 
 //----- (0044100D) --------------------------------------------------------
@@ -6648,10 +6569,7 @@
 
   uLevelStrNumStrings = string_num - 1;
   if ( max_string_length > 800 )
-  {
-    sprintf(Args, "MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length+1);
-    Abortf(Args);
-  }
+    Error("MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length+1);
 
   if ( uLevelStrNumStrings > 0 )
   {
@@ -6846,10 +6764,10 @@
   char pContainerName[120]; // [sp+8h] [bp-98h]@1
 
   sprintf(pContainerName, "%s.evt", pLevelName);
-  uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 0x2400u);
+  uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 9216);
 
   sprintf(pContainerName, "%s.str", pLevelName);
-  uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 0x2400u);
+  uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 9216);
   if (uLevelStrFileSize)
     LoadLevel_InitializeLevelStr();
 }
@@ -6918,7 +6836,7 @@
             v12 = v11->sCogTriggeredID;
             if ( v12 )
             {
-              if ( !(BYTE2(v11->uAttributes) & 0x10) )
+              if ( !(v11->uAttributes & 0x100000) )
               {
                 v13 = GetEventHintString(v12);
                 v14 = v13;
@@ -6985,7 +6903,7 @@
 }
 
 //----- (004452BB) --------------------------------------------------------
-void  sub_4452BB()
+void sub_4452BB()
 {
   pGUIWindow2->Release();
   pGUIWindow2 = 0;
@@ -7466,7 +7384,7 @@
   if ( v10 )
   {
     v11 = uNumActors;
-    SpawnEncounter((MapInfo *)&pMapStats->pInfos[v10], &v16, 0, count, 0);
+    SpawnEncounter(&pMapStats->pInfos[v10], &v16, 0, count, 0);
     memcpy(&v15, Actor::GetDirectionInfo(PID(OBJECT_Actor, v11), 4u, &a3, 1), sizeof(v15));
     v12 = v11;
     if ( (signed int)v11 < (signed int)uNumActors )
@@ -7482,7 +7400,6 @@
   }
 }
 
-// 4EE088: using guessed type __int16 word_4EE088_sound_ids[];
 
 //----- (0044987B) --------------------------------------------------------
 void sub_44987B(const char *pMapName, MapStartPoint start_point)
@@ -7523,6 +7440,8 @@
     case MapStartPoint_South: v10 = "South Start"; break;
     case MapStartPoint_East: v10 = "East Start";  break;
     case MapStartPoint_West: v10 = "West Start";  break;
+    default:
+      Error("Invalid enum value: %u", point);
   }
 
   strcpy(pName, v10);
@@ -7595,7 +7514,7 @@
   unsigned int v7; // edx@18
   signed int v8; // esi@19
   int v9; // eax@19
-  char Args; // [sp+Ch] [bp-78h]@6
+  //char Args; // [sp+Ch] [bp-78h]@6
 
   LOWORD(v2) = LOWORD(pIndoor->pDoors);
   v3 = a2;
@@ -7613,8 +7532,7 @@
   while ( v4 < 200 );
   if ( v4 >= 200 )
   {
-    sprintf(&Args, "Unable to find Door ID: %i!", uDoorID);
-    Abortf(&Args);
+    Error("Unable to find Door ID: %i!", uDoorID);
   }
   v6 = &pIndoor->pDoors[v4];
   if ( v3 == 2 )
@@ -7699,14 +7617,11 @@
 
 //----- (0044C175) --------------------------------------------------------
 void ShowStatusBarString( const char *pString, unsigned int uNumSeconds )
-    {
-  unsigned int v2; // esi@1
-  int i; // eax@1
-
-  v2 = uNumSeconds;
+{
   strcpy(GameUI_Footer_TimedString.data(), pString);
-  GameUI_Footer_TimeLeft = 1000 * v2 + GetTickCount();
-  for ( i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data());
+  GameUI_Footer_TimeLeft = 1000 * uNumSeconds + GetTickCount();
+
+  for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data());
         i > 450;
         i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) )
     GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0;
@@ -7716,7 +7631,7 @@
 void ShowNothingHereStatus()
 {
   if ( !GameUI_Footer_TimeLeft )
-    ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here
+    ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2);// Nothing here
 }
 
 //----- (0044C28B) --------------------------------------------------------
@@ -7766,23 +7681,18 @@
 }
 
 //----- (0040261D) --------------------------------------------------------
-int stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8)
+void stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8)
 {
-  int result; // eax@1
-
-  result = this->count;
-  if ( this->count < 100 )
-  {
-    this->pIDs[result] = uID;
-    this->pXs[this->count] = x;
-    this->pYs[this->count] = y;
-    this->pZs[this->count] = z;
-    this->field_324[this->count] = a3;
-    this->field_3EC[this->count] = a8;
-    result = this->count;
-    this->field_450[this->count++] = a7;
-  }
-  return result;
+  if (count < 100)
+  {
+    pIDs[count] = uID;
+    pXs[count] = x;
+    pYs[count] = y;
+    pZs[count] = z;
+    field_324[count] = a3;
+    field_3EC[count] = a8;
+    field_450[count++] = a7;
+  }
 }
 
 //----- (00402CAE) --------------------------------------------------------
--- a/mm7_4.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7_4.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "Texture.h"
 #include "mm7_data.h"
 #include "VideoPlayer.h"
@@ -360,16 +358,15 @@
                     v16 = v4 - stru_721530.normal.x;
                     v15 = v5 - stru_721530.normal.y;
                     v8 = stru_721530.prolly_normal_d + v3;
-                    v17 = ((v4 - stru_721530.normal.x) * stru_721530.field_58.y
-                         - (v5 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
+                    v17 = ((v4 - stru_721530.normal.x) * stru_721530.direction.y
+                         - (v5 - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
                     if ( abs(v17) <= stru_721530.prolly_normal_d + v3 )
                     {
-                      v9 = (v16 * stru_721530.field_58.x + v15 * stru_721530.field_58.y) >> 16;
+                      v9 = (v16 * stru_721530.direction.x + v15 * stru_721530.direction.y) >> 16;
                       if ( v9 > 0 )
                       {
                         v10 = v1->vPosition.z;
-                        v11 = stru_721530.normal.z
-                            + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v9) >> 16);
+                        v11 = stru_721530.normal.z + fixpoint_sub0(stru_721530.direction.z, v9);
                         if ( v11 >= v10 )
                         {
                           if ( v11 <= v18 + v10 )
@@ -1558,7 +1555,7 @@
   v2 = fopen("data\\dpft.bin", "wb");
   v3 = v2;
   if ( !v2 )
-    Abortf("Unable to save dpft.bin!");
+    Error("Unable to save dpft.bin");
   fwrite(v1, 4u, 1u, v2);
   fwrite(v1->pFrames, 0xAu, v1->uNumFrames, v3);
   fclose(v3);
@@ -1615,7 +1612,7 @@
   v3 = fopen(Args, "r");
   File = v3;
   if ( !v3 )
-    Abortf("PlayerFrameTable::load - Unable to open file: %s.", Args);
+    Error("PlayerFrameTable::load - Unable to open file: %s.", Args);
   v4 = 0;
   v25 = 0;
   v26 = 1;
@@ -1628,7 +1625,7 @@
       if ( v24.uPropCount && *v24.pProperties[0] != 47 )
       {
         if ( v24.uPropCount < 3 )
-          Abortf("PlayerFrameTable::load, too few arguments, %s line %i.", Args, v26);
+          Error("PlayerFrameTable::load, too few arguments, %s line %i.", Args, v26);
         ++v25;
       }
       ++v26;
@@ -1640,7 +1637,7 @@
   v5 = pAllocator->AllocNamedChunk(v2->pFrames, 10 * v4, "P Frames");
   v2->pFrames = (PlayerFrame *)v5;
   if ( !v5 )
-    Abortf("PlayerFrameTable::load - Out of Memory!");
+    Error("PlayerFrameTable::load - Out of Memory!");
   v6 = File;
   v2->uNumFrames = 0;
   fseek(v6, 0, 0);
--- a/mm7_5.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7_5.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -2,8 +2,6 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
-#include <assert.h>
-
 #include "Texture.h"
 #include "mm7_data.h"
 #include "VideoPlayer.h"
@@ -3837,9 +3835,7 @@
   }
   stru_50FE08.count = 0;
 }
-// 50FE08: using guessed type stru298 stru_50FE08;
 
-// 4D864C: using guessed type char byte_4D864C;
 
 //----- (0043A97E) --------------------------------------------------------
 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2)
@@ -4674,8 +4670,8 @@
   int v21; // edi@20
   signed int v22; // eax@22
   signed __int64 v23; // qtt@22
-  bool result; // eax@25
-  int v25; // [sp+14h] [bp-8h]@14
+  //bool result; // eax@25
+  //int v25; // [sp+14h] [bp-8h]@14
   int a4a; // [sp+28h] [bp+Ch]@2
   signed int a5a; // [sp+2Ch] [bp+10h]@14
 
@@ -4725,23 +4721,24 @@
     {
 	  if( dword_4F5BF4_xs[i + 2] >= a4a || dword_4F5BF4_xs[i] >= a4a)
       {
-		  if ( (dword_4F5BF4_xs[i + 2] >= a4a && dword_4F5BF4_xs[i + 1] >= a4a)
-          || (v25 = dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1],
-              LODWORD(v23) = v25 << 16,
-              HIDWORD(v23) = v25 >> 16,
-              dword_4F5BF4_xs[i + 1]
-            + ((signed int)(((unsigned __int64)(v23
-                                              / (dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1])
-                                              * ((a3 - dword_4F5B24_ys[i + 1]) << 16)) >> 16)
-                          + 32768) >> 16) >= a4a) )
-          ++a5a;
+		  if (dword_4F5BF4_xs[i + 2] >= a4a && dword_4F5BF4_xs[i + 1] >= a4a)
+            ++a5a;
+          else
+          {
+              v23 = (__int64)(dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1]) << 16;
+              __int64 _a = dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1];
+              __int64 _b = (__int64)(a3 - dword_4F5B24_ys[i + 1]) << 16;
+
+              if (dword_4F5BF4_xs[i + 1] + ((((v23 / _a * _b) >> 16) + 32768) >> 16) >= a4a)
+                ++a5a;
+          }
 	  }
     }
   }
-  result = 1;
+
   if ( a5a != 1 )
-    result = 0;
-  return result;
+    return false;
+  return true;
 
 }
 
--- a/mm7_6.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7_6.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1675,14 +1675,14 @@
 
 
 //----- (0042FA66) --------------------------------------------------------
-int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6)
+void _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6)
 {
   int v6; // edi@1
   int v7; // esi@1
   char *v8; // ecx@2
   unsigned __int16 v9; // ax@5
   //int v10; // eax@10
-  signed int result; // eax@11
+  //signed int result; // eax@11
   //__int16 v12; // ax@12
   //SpriteObject a1a; // [sp+Ch] [bp-74h]@1
   int v14; // [sp+7Ch] [bp-4h]@1
@@ -1734,18 +1734,16 @@
   {
     a1a.spell_caster_pid = 0;
   }
-  result = a1a.Create(0, 0, 0, 0);
-  if ( result != -1 )
-  {
-    result = stru_50FE08.Add(PID(OBJECT_Item, result),
+
+  int id = a1a.Create(0, 0, 0, 0);
+  if (id != -1)
+    stru_50FE08.Add(PID(OBJECT_Item, id),
                a5,
                SLOWORD(a1a.vPosition.x),
                SLOWORD(a1a.vPosition.y),
                SLOWORD(a1a.vPosition.z),
                0,
                0);
-  }
-  return result;
 }
 
 //----- (0042FB5C) --------------------------------------------------------
--- a/mm7_data.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7_data.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1206,7 +1206,6 @@
 int uWindowX; // idb
 int uWindowY; // idb
 LONG uWindowStyle; // idb
-HMENU hOSMenu; // idb
 int dword_6BE340; // weak
 char pCurrentMapName[32]; // idb
 unsigned int uLevelMapStatsID;
@@ -1237,7 +1236,6 @@
 bool bNoLogo = false;
 bool bNoCD = false;
 bool bNoSound = false;
-int aborting_app; // weak
 std::array<int, 100> dword_720020_zvalues;
 std::array<int, 299> dword_7201B0_zvalues;
 int uTextureID_720980; // weak
--- a/mm7_data.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7_data.h	Sat Sep 07 21:14:48 2013 +0200
@@ -858,7 +858,6 @@
 extern int uWindowX; // idb
 extern int uWindowY; // idb
 extern LONG uWindowStyle; // idb
-extern HMENU hOSMenu; // idb
 extern int dword_6BE340; // weak
 extern char pCurrentMapName[32]; // idb
 extern unsigned int uLevelMapStatsID;
@@ -889,7 +888,6 @@
 extern bool bNoLogo;
 extern bool bNoCD;
 extern bool bNoSound;
-extern int aborting_app; // weak
 extern std::array<int, 100> dword_720020_zvalues;
 extern std::array<int, 299> dword_7201B0_zvalues;
 extern int dword_7207F0[]; // idb
@@ -1135,7 +1133,7 @@
 bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9);
 void __fastcall sub_42F960_create_object(int x, int y, int z); // idb
 void CompactLayingItemsList();
-int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6);
+void _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6);
 bool _42FB5C_check_spell(signed int a1);
 void sub_42FBDD();
 void CloseWindowBackground();
@@ -1166,7 +1164,7 @@
 int __fastcall _43F55F_get_billboard_light_level(struct RenderBillboard *a1, int uBaseLightLevel);
 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z);
 void PrepareBspRenderList_BLV();
-void __fastcall PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID);
+void PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID);
 void PrepareActorRenderList_BLV();
 void PrepareItemsRenderList_BLV();
 void AddBspNodeToRenderList(unsigned int node_id);
@@ -1217,8 +1215,6 @@
 void CreateAsyncKeyboard();
 void MM6_Initialize(const wchar_t *pIniFilename);
 void MM7Initialization();
-int AbortWithError();
-void Abortf(const char *Format, ...);
 void SetCurrentMenuID(enum MENU_STATE); // idb
 enum MENU_STATE GetCurrentMenuID();
 void CreateMsgScrollWindow(signed int mscroll_id);
@@ -1261,7 +1257,6 @@
 unsigned int WorldPosToGridCellZ(int); // weak
 int GridCellToWorldPosX(int); // weak
 int GridCellToWorldPosZ(int); // weak
-void ResetPolygons();
 void sub_481ED9_MessWithOutdoorCamera();
 bool IsTerrainSlopeTooHigh(int pos_x, int pos_y);
 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4);
--- a/mm7text_ru.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/mm7text_ru.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -5,9 +5,9 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <assert.h>
 
 #include "Log.h"
+#include "ErrorHandling.h"
 
 
 struct GenderTableEntry
@@ -1161,14 +1161,14 @@
   return nullptr;
 }
 
-int  sprintfex_internal(char *str)
+int sprintfex_internal(char *str)
 {
   auto p = strstr(str, "^");
   if (!p)
     return strlen(str);
 
   char buf[8192];
-  assert(strlen(str) < sizeof(buf));
+  Assert(strlen(str) < sizeof(buf));
 
   int next_integer_token = 0;
   bool integer_tokens_defined[10] = {false, false, false, false, false, false, false, false, false, false};
@@ -1190,7 +1190,7 @@
           goto _invalid_token;
         src += 3;  // ^I[
         
-        assert(next_integer_token < 10);
+        Assert(next_integer_token < 10);
         if (sscanf(src, "%d", &integer_tokens[next_integer_token]))
           integer_tokens_defined[next_integer_token++] = true;
 
@@ -1217,7 +1217,7 @@
         else if (src[2] != '[')
           goto _invalid_token;
 
-        assert(integer_tokens_defined[integer_token_idx]);
+        Assert(integer_tokens_defined[integer_token_idx]);
         src += 3; // ^L[
 
         auto ending1 = src;
@@ -1256,7 +1256,7 @@
       {
         if (src[2] != '[')
           goto _invalid_token;
-        assert(gender_token_defined);
+        Assert(gender_token_defined);
 
         src += 3; // ^R[
 
@@ -1285,7 +1285,7 @@
           actual_ending = ending3;
           actual_ending_len = src - ending3 - 1;
         }
-        else assert(false);
+        else Error("Invalid gender token");
 
         strncpy(dst, actual_ending, actual_ending_len);
         dst += actual_ending_len;
@@ -1367,8 +1367,7 @@
         strncpy(token, token_begin, token_len);
         token[token_len] = 0;
 
-        Log::Warning(L"Invalid format token: %S", token);
-        assert(false);
+        Error("Invalid format token: %s", token);
       }
       break;
     }
--- a/stru10.cpp	Sat Sep 07 21:00:02 2013 +0200
+++ b/stru10.cpp	Sat Sep 07 21:14:48 2013 +0200
@@ -1,10 +1,9 @@
-#include <assert.h>
-
 #include "stru10.h"
 #include "Render.h"
 #include "Indoor.h"
 #include "Game.h"
 #include "Party.h"
+#include "ErrorHandling.h"
 
 #include "mm7_data.h"
 
@@ -81,7 +80,7 @@
 //----- (0049CE9E) --------------------------------------------------------
 void stru10::_49CE9E(BLVFace *pFace, RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *pOutLimits)
 {
-  assert(sizeof(RenderVertexSoft) == 0x30);
+  Assert(sizeof(RenderVertexSoft) == 0x30);
   
   RenderVertexSoft pLimits[64];
   stru10::CalcPolygonLimits(pFace, pLimits);
@@ -273,7 +272,7 @@
     break;
 
     default:
-      assert(false);
+      Error("Invalid polygon type (%u)", pFace->uPolygonType);
   }
 
 
--- a/stru298.h	Sat Sep 07 21:00:02 2013 +0200
+++ b/stru298.h	Sat Sep 07 21:14:48 2013 +0200
@@ -4,7 +4,7 @@
 #pragma pack(push, 1)
 struct stru298
 {
-  int Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8);
+  void Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8);
 
   int count;
   __int16 pIDs[100];