]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/bobtoolz/cportals.cpp
Merge commit 'af4e2d29cfd3a54b44eb09e4289f3fa3f29412c9' into garux-merge
[xonotic/netradiant.git] / contrib / bobtoolz / cportals.cpp
index c408eda2fde7753fa8ecb55172b00cd4cc2bde92..d8ec2a6086b8cb073d23ea557aef23608f3af35c 100644 (file)
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "StdAfx.h"
 #include "CPortals.h"
+
+#include <string.h>
+#include <math.h>
+
 #include "misc.h"
 
-#define LINE_BUF 1000
-#define MSG_PREFIX "bobToolz plugin: "
+const int LINE_BUF = 1000;
+const char *MSG_PREFIX = "bobToolz plugin: ";
 
 // these classes are far less of a mess than my code was,
 // thanq to G.DeWan 4 the prtview source on which it was based
@@ -44,11 +47,11 @@ void ClampFloat( float* p ){
        }
 
        if ( fabs( *p - ceil( *p ) ) < MAX_ROUND_ERROR ) {
-               *p = ceilf( *p );
+               *p = static_cast<float>( ceil( *p ) );
        }
 
        if ( fabs( *p - floor( *p ) ) < MAX_ROUND_ERROR ) {
-               *p = floorf( *p );
+               *p = static_cast<float>( floor( *p ) );
        }
 }
 
@@ -59,7 +62,7 @@ bool CBspPortal::Build( char *def, unsigned int pointCnt, bool bInverse ){
        point_count = pointCnt;
 
        if ( point_count < 3 ) {
-               return FALSE;
+               return false;
        }
 
        point = new CBspPoint[point_count];
@@ -69,7 +72,7 @@ bool CBspPortal::Build( char *def, unsigned int pointCnt, bool bInverse ){
                for (; *c != 0 && *c != '('; c++ ) ;
 
                if ( *c == 0 ) {
-                       return FALSE;
+                       return false;
                }
 
                c++;
@@ -89,7 +92,7 @@ bool CBspPortal::Build( char *def, unsigned int pointCnt, bool bInverse ){
                ClampFloat( &point[x].p[2] );
        }
 
-       return TRUE;
+       return true;
 }
 
 CPortals::CPortals(){
@@ -115,14 +118,14 @@ void CPortals::Load(){
 
        Purge();
 
-       Sys_Printf( MSG_PREFIX "Loading portal file %s.\n", fn );
+       globalOutputStream() << MSG_PREFIX << "Loading portal file " << fn << ".\n";
 
        FILE *in;
 
        in = fopen( fn, "rt" );
 
        if ( in == NULL ) {
-               Sys_Printf( "  ERROR - could not open file.\n" );
+               globalOutputStream() << "  ERROR - could not open file.\n";
 
                return;
        }
@@ -130,7 +133,7 @@ void CPortals::Load(){
        if ( !fgets( buf, LINE_BUF, in ) ) {
                fclose( in );
 
-               Sys_Printf( "  ERROR - File ended prematurely.\n" );
+               globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                return;
        }
@@ -138,7 +141,7 @@ void CPortals::Load(){
        if ( strncmp( "PRT1", buf, 4 ) != 0 ) {
                fclose( in );
 
-               Sys_Printf( "  ERROR - File header indicates wrong file type (should be \"PRT1\").\n" );
+               globalOutputStream() << "  ERROR - File header indicates wrong file type (should be \"PRT1\").\n";
 
                return;
        }
@@ -146,7 +149,7 @@ void CPortals::Load(){
        if ( !fgets( buf, LINE_BUF, in ) ) {
                fclose( in );
 
-               Sys_Printf( "  ERROR - File ended prematurely.\n" );
+               globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                return;
        }
@@ -158,7 +161,7 @@ void CPortals::Load(){
 
                node_count = 0;
 
-               Sys_Printf( "  ERROR - Extreme number of nodes, aborting.\n" );
+               globalOutputStream() << "  ERROR - Extreme number of nodes, aborting.\n";
 
                return;
        }
@@ -168,7 +171,7 @@ void CPortals::Load(){
 
                node_count = 0;
 
-               Sys_Printf( "  ERROR - File ended prematurely.\n" );
+               globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                return;
        }
@@ -181,7 +184,7 @@ void CPortals::Load(){
 
                node_count = 0;
 
-               Sys_Printf( "  ERROR - File ended prematurely.\n" );
+               globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                return;
        }
@@ -199,7 +202,7 @@ void CPortals::Load(){
 
                        node_count = 0;
 
-                       Sys_Printf( "  ERROR - File ended prematurely.\n" );
+                       globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                        return;
                }
@@ -218,7 +221,7 @@ void CPortals::Load(){
 
                        node_count = 0;
 
-                       Sys_Printf( "  ERROR - File ended prematurely.\n" );
+                       globalOutputStream() << "  ERROR - File ended prematurely.\n";
 
                        return;
                }
@@ -249,7 +252,7 @@ void CPortals::Load(){
 
                        Purge();
 
-                       Sys_Printf( "  ERROR - Could not find information for portal number %d of %d.\n", n + 1, p_count );
+                       globalOutputStream() << "  ERROR - Could not find information for portal number " << n + 1 << " of " << p_count << ".\n";
 
                        return;
                }
@@ -257,22 +260,22 @@ void CPortals::Load(){
                unsigned int pCount, node1, node2;
                sscanf( buf, "%u %u %u", &pCount, &node1, &node2 );
 
-               if ( !node[node1].AddPortal( buf, pCount, FALSE ) ) {
+               if ( !node[node1].AddPortal( buf, pCount, false ) ) {
                        fclose( in );
 
                        Purge();
 
-                       Sys_Printf( "  ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count );
+                       globalOutputStream() << "  ERROR - Information for portal number " << n + 1 << " of " << p_count << " is not formatted correctly.\n";
 
                        return;
                }
 
-               if ( !node[node2].AddPortal( buf, pCount, TRUE ) ) {
+               if ( !node[node2].AddPortal( buf, pCount, true ) ) {
                        fclose( in );
 
                        Purge();
 
-                       Sys_Printf( "  ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count );
+                       globalOutputStream() << "  ERROR - Information for portal number " << n + 1 << " of " << p_count << " is not formatted correctly.\n";
 
                        return;
                }
@@ -285,7 +288,7 @@ void CPortals::Load(){
 
                        Purge();
 
-                       Sys_Printf( "  ERROR - Could not find information for portal number %d of %d.\n", n + 1, p_count );
+                       globalOutputStream() << "  ERROR - Could not find information for portal number " << n + 1 << " of " << p_count << ".\n";
 
                        return;
                }
@@ -293,12 +296,12 @@ void CPortals::Load(){
                unsigned int pCount, node1;
                sscanf( buf, "%u %u", &pCount, &node1 );
 
-               if ( !node[node1].AddPortal( buf, pCount, FALSE ) ) {
+               if ( !node[node1].AddPortal( buf, pCount, false ) ) {
                        fclose( in );
 
                        Purge();
 
-                       Sys_Printf( "  ERROR - Information for portal number %d of %d is not formatted correctly.\n", n + 1, p_count );
+                       globalOutputStream() << "  ERROR - Information for portal number " << n + 1 << " of " << p_count << " is not formatted correctly.\n";
 
                        return;
                }