summaryrefslogtreecommitdiff
path: root/src/win95
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.si>2022-06-12 16:53:06 +0200
committerTimotej Lazar <timotej.lazar@araneo.si>2022-06-12 16:53:06 +0200
commit1e38669119d4ce3e06bbad603799e32e6fd7feb2 (patch)
treee787ac4dac41be1f8bcdbeab22c3bbee64f0d8b7 /src/win95
parent0aa9a623f3b38e35b7f1cd26da0237beca2c9988 (diff)
Replace max macro with std::max in C++ code
Fixes compilation on Guix with gcc 12. Not sure which of those is relevant.
Diffstat (limited to 'src/win95')
-rw-r--r--src/win95/bmpnames.cpp3
-rw-r--r--src/win95/chnkload.cpp19
-rw-r--r--src/win95/chnktype.cpp15
-rw-r--r--src/win95/inline.h2
-rw-r--r--src/win95/ltchunk.cpp10
-rw-r--r--src/win95/mishchnk.cpp10
-rw-r--r--src/win95/shpchunk.cpp19
7 files changed, 44 insertions, 34 deletions
diff --git a/src/win95/bmpnames.cpp b/src/win95/bmpnames.cpp
index b27e4ea..56c1282 100644
--- a/src/win95/bmpnames.cpp
+++ b/src/win95/bmpnames.cpp
@@ -1,3 +1,4 @@
+#include <algorithm>
#include <string.h>
#include "bmpnames.hpp"
#include "mishchnk.hpp"
@@ -128,7 +129,7 @@ Chunk_With_BMPs::Chunk_With_BMPs (Chunk_With_Children * parent, const char * con
bn.priority = d2;
bn.transparency_colour_union = d3;
- max_index = max (bn.index, max_index);
+ max_index = std::max(bn.index, max_index);
bmps.add_entry (bn);
}
diff --git a/src/win95/chnkload.cpp b/src/win95/chnkload.cpp
index 99bc0a5..ee31b24 100644
--- a/src/win95/chnkload.cpp
+++ b/src/win95/chnkload.cpp
@@ -1,3 +1,4 @@
+#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
@@ -672,7 +673,7 @@ static void setup_tex_conv_array (
for (; !bns.done(); bns.next())
{
- max_indices = max(bns().index,max_indices);
+ max_indices = std::max(bns().index,max_indices);
}
conv_array = new int [max_indices+1];
@@ -1177,7 +1178,7 @@ BOOL load_rif_bitmaps (RIFFHANDLE h, int/* flags*/)
for (; !bns.done(); bns.next())
{
- h->max_index = max(bns().index,h->max_index);
+ h->max_index = std::max(bns().index,h->max_index);
}
if (h->tex_index_nos) delete h->tex_index_nos;
@@ -1619,7 +1620,7 @@ void DeallocateRifLoadedShapeheader(SHAPEHEADER * shp)
if (is_textured(shp->items[i][0]))
{
int UVIndex = (shp->items[i][3] &0xffff0000) >> 16;
- max_num_texs = max (max_num_texs, shp->items[i][3] &0x7fff);
+ max_num_texs = std::max(max_num_texs, shp->items[i][3] &0x7fff);
if(shp->items[i][2]& iflag_txanim)
{
int j;
@@ -2138,7 +2139,7 @@ void SetupAnimatingShape(Shape_Chunk* sc,SHAPEHEADER* shp, Shape_Merge_Data_Chun
for(;!chlif.done();chlif.next())
{
Anim_Shape_Sequence_Chunk* assc=(Anim_Shape_Sequence_Chunk*)chlif();
- numseq=max(assc->sequence_data.SequenceNum+1,numseq);
+ numseq=std::max(assc->sequence_data.SequenceNum+1,numseq);
}
shapeanimationheader* sah=(shapeanimationheader*)PoolAllocateMem(sizeof(shapeanimationheader));
@@ -2173,9 +2174,9 @@ void SetupAnimatingShape(Shape_Chunk* sc,SHAPEHEADER* shp, Shape_Merge_Data_Chun
sas->max_z=(int)((cas->max.z-Centre.z)*local_scale);
sas->min_z=(int)((cas->min.z-Centre.z)*local_scale);
- int x=max(-sas->min_x,sas->max_x);
- int y=max(-sas->min_y,sas->max_y);
- int z=max(-sas->min_z,sas->max_z);
+ int x=std::max(-sas->min_x,sas->max_x);
+ int y=std::max(-sas->min_y,sas->max_y);
+ int z=std::max(-sas->min_z,sas->max_z);
sas->radius=(int)sqrt((double)(x*x+y*y+z*z));
@@ -2609,7 +2610,7 @@ BOOL copy_sprite_to_shapeheader (RIFFHANDLE h, SHAPEHEADER *& shphd,Sprite_Heade
LIF<BMP_Name> bns (&blsc->bmps);
for (; !bns.done(); bns.next())
{
- local_max_index = max(bns().index,local_max_index);
+ local_max_index = std::max(bns().index,local_max_index);
}
BmpConv = new int [local_max_index+1];
@@ -2771,7 +2772,7 @@ BOOL copy_sprite_to_shapeheader (RIFFHANDLE h, SHAPEHEADER *& shphd,Sprite_Heade
int MaxSeq=0;
for(LIF<Chunk*>chlif(&chlist);!chlif.done();chlif.next())
{
- MaxSeq=max(MaxSeq,((Sprite_Action_Chunk*)chlif())->Action);
+ MaxSeq=std::max(MaxSeq,((Sprite_Action_Chunk*)chlif())->Action);
}
txanimheader** thlist=(txanimheader**)PoolAllocateMem((3+MaxSeq)*sizeof(txanimheader));
thlist[0]=thlist[MaxSeq+2]=0;
diff --git a/src/win95/chnktype.cpp b/src/win95/chnktype.cpp
index 4612cdf..123f697 100644
--- a/src/win95/chnktype.cpp
+++ b/src/win95/chnktype.cpp
@@ -1,4 +1,5 @@
#include "chunk.hpp"
+#include <algorithm>
#include <math.h>
#include "chnktype.hpp"
@@ -1044,17 +1045,17 @@ void ChunkAnimSequence::UpdateNormalsAndExtents(ChunkShape const * cs,List<int>*
for (int j=0; j<caf->num_verts; j++)
{
if(vert_in_bb && !vert_in_bb[j]) continue;
- max.x = max(max.x, caf->v_list[j].x);
- max.y = max(max.y, caf->v_list[j].y);
- max.z = max(max.z, caf->v_list[j].z);
+ max.x = std::max(max.x, caf->v_list[j].x);
+ max.y = std::max(max.y, caf->v_list[j].y);
+ max.z = std::max(max.z, caf->v_list[j].z);
- min.x = min(min.x, caf->v_list[j].x);
- min.y = min(min.y, caf->v_list[j].y);
- min.z = min(min.z, caf->v_list[j].z);
+ min.x = std::min(min.x, caf->v_list[j].x);
+ min.y = std::min(min.y, caf->v_list[j].y);
+ min.z = std::min(min.z, caf->v_list[j].z);
double temp_rad = mod(caf->v_list[j]);
- radius = max (radius, (float)temp_rad);
+ radius = std::max(radius, (float)temp_rad);
}
}
if(vert_in_bb) delete [] vert_in_bb;
diff --git a/src/win95/inline.h b/src/win95/inline.h
index dcb9dff..bfdcf8f 100644
--- a/src/win95/inline.h
+++ b/src/win95/inline.h
@@ -1,6 +1,7 @@
#ifndef INLINE_INCLUDED
#define INLINE_INCLUDED
+#ifndef __cplusplus
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
@@ -8,6 +9,7 @@
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
+#endif
#if SUPPORT_MMX
diff --git a/src/win95/ltchunk.cpp b/src/win95/ltchunk.cpp
index 78bd44f..a258467 100644
--- a/src/win95/ltchunk.cpp
+++ b/src/win95/ltchunk.cpp
@@ -1,3 +1,5 @@
+#include <algorithm>
+
#include "chunk.hpp"
#include "ltchunk.hpp"
@@ -331,8 +333,8 @@ int Light_Scale_Chunk::ApplyPrelightScale(int l)
l+=(prelight_add-prelight_multiply_above);
l= (int)(l*prelight_multiply);
l+=prelight_multiply_above;
- l=min(l,255);
- return max(l,prelight_multiply_above);
+ l=std::min(l,255);
+ return std::max(l,prelight_multiply_above);
}
int Light_Scale_Chunk::ApplyRuntimeScale(int l)
{
@@ -340,8 +342,8 @@ int Light_Scale_Chunk::ApplyRuntimeScale(int l)
l+=(runtime_add-runtime_multiply_above);
l=(int)( l*runtime_multiply);
l+=runtime_multiply_above;
- l=min(l,255);
- return max(l,runtime_multiply_above);
+ l=std::min(l,255);
+ return std::max(l,runtime_multiply_above);
}
////////////////////////////////////////////////////////////////////////////////////
RIF_IMPLEMENT_DYNCREATE("PLOBJLIT",Placed_Object_Light_Chunk)
diff --git a/src/win95/mishchnk.cpp b/src/win95/mishchnk.cpp
index b4521c3..2c3777b 100644
--- a/src/win95/mishchnk.cpp
+++ b/src/win95/mishchnk.cpp
@@ -1,3 +1,5 @@
+#include <algorithm>
+
#include "chunk.hpp"
#include "chnktype.hpp"
#include "mishchnk.hpp"
@@ -625,7 +627,7 @@ void File_Chunk::post_input_processing()
LIF<Shape_Chunk *> sli(&shplist);
for (; !sli.done(); sli.next())
{
- Shape_Chunk::max_id = max (Shape_Chunk::max_id,sli()->get_header()->file_id_num);
+ Shape_Chunk::max_id = std::max(Shape_Chunk::max_id,sli()->get_header()->file_id_num);
}
Shape_Chunk** shape_array=new Shape_Chunk*[Shape_Chunk::max_id+1];
@@ -803,7 +805,7 @@ BOOL File_Chunk::check_file()
// Here we update max_id
- Shape_Chunk::max_id = max (Shape_Chunk::max_id,id);
+ Shape_Chunk::max_id = std::max(Shape_Chunk::max_id,id);
// go to version number
SetFilePointer(rif_file,shphead.first_entry() + 100,0,FILE_BEGIN);
@@ -1515,7 +1517,7 @@ void File_Chunk::build_object_array()
//find the highest object index
for(oblif.restart();!oblif.done();oblif.next())
{
- object_array_size=max(object_array_size,oblif()->object_data.index_num+1);
+ object_array_size=std::max(object_array_size,oblif()->object_data.index_num+1);
}
if(object_array_size<=0) return;
@@ -1864,7 +1866,7 @@ void RIF_File_Chunk::post_input_processing()
for (LIF<Shape_Chunk *> sli(&shplist); !sli.done(); sli.next())
{
- Shape_Chunk::max_id = max (Shape_Chunk::max_id,sli()->get_header()->file_id_num);
+ Shape_Chunk::max_id = std::max(Shape_Chunk::max_id,sli()->get_header()->file_id_num);
}
Chunk_With_Children::post_input_processing();
diff --git a/src/win95/shpchunk.cpp b/src/win95/shpchunk.cpp
index 26058af..f5338ea 100644
--- a/src/win95/shpchunk.cpp
+++ b/src/win95/shpchunk.cpp
@@ -1,3 +1,4 @@
+#include <algorithm>
#include <math.h>
#include "unaligned.h"
#include "chunk.hpp"
@@ -191,17 +192,17 @@ void Shape_Chunk::post_input_processing()
for (int i=0; i<shape_data_store->num_verts; i++)
{
- max.x = max(max.x, shape_data_store->v_list[i].x);
- max.y = max(max.y, shape_data_store->v_list[i].y);
- max.z = max(max.z, shape_data_store->v_list[i].z);
+ max.x = std::max(max.x, shape_data_store->v_list[i].x);
+ max.y = std::max(max.y, shape_data_store->v_list[i].y);
+ max.z = std::max(max.z, shape_data_store->v_list[i].z);
- min.x = min(min.x, shape_data_store->v_list[i].x);
- min.y = min(min.y, shape_data_store->v_list[i].y);
- min.z = min(min.z, shape_data_store->v_list[i].z);
+ min.x = std::min(min.x, shape_data_store->v_list[i].x);
+ min.y = std::min(min.y, shape_data_store->v_list[i].y);
+ min.z = std::min(min.z, shape_data_store->v_list[i].z);
float temp_rad =(float) mod(shape_data_store->v_list[i]);
- radius = max (radius, temp_rad);
+ radius = std::max(radius, temp_rad);
}
shape_data_store->max = max;
@@ -1459,7 +1460,7 @@ void Shape_Header_Chunk::prepare_for_output()
}
- Shape_Chunk::max_id = max(Shape_Chunk::max_id, file_id_num);
+ Shape_Chunk::max_id = std::max(Shape_Chunk::max_id, file_id_num);
// this should always be the last thing
@@ -1783,7 +1784,7 @@ void Shape_Morphing_Data_Chunk::prepare_for_output()
for (; !cli.done(); cli.next())
{
- max_id = max (max_id, ((Shape_Sub_Shape_Chunk *)cli())->get_header()->file_id_num);
+ max_id = std::max(max_id, ((Shape_Sub_Shape_Chunk *)cli())->get_header()->file_id_num);
}
for (cli.restart(); !cli.done(); cli.next())