diff --git a/src/avp/win95/avpchunk.cpp b/src/avp/win95/avpchunk.cpp index b247797..9cc8b95 100644 --- a/src/avp/win95/avpchunk.cpp +++ b/src/avp/win95/avpchunk.cpp @@ -1,3 +1,5 @@ +#include + #include "avpchunk.hpp" #include "md5.h" //#include "strachnk.hpp" @@ -280,7 +282,7 @@ AVP_Generator_Extended_Settings_Chunk::AVP_Generator_Extended_Settings_Chunk(Chu CHUNK_EXTRACT(spare2,int) - size_t size=max(*(int*) data,(int)sizeof(AVP_Generator_Weighting)); + size_t size=std::max(*(int*) data,(int)sizeof(AVP_Generator_Weighting)); weights=(AVP_Generator_Weighting*)new unsigned char[size]; memset(weights,0,sizeof(AVP_Generator_Weighting)); @@ -551,7 +553,7 @@ RIF_IMPLEMENT_DYNCREATE("AVPENVIR",AVP_Environment_Settings_Chunk) AVP_Environment_Settings_Chunk::AVP_Environment_Settings_Chunk(Chunk_With_Children* parent,const char* data,size_t data_size) :Chunk(parent,"AVPENVIR") { - size_t size=max(data_size,sizeof(AVP_Environment_Settings)); + size_t size=std::max(data_size,sizeof(AVP_Environment_Settings)); settings=(AVP_Environment_Settings*)new unsigned char[size]; memcpy(settings,data,data_size); @@ -642,7 +644,7 @@ AVP_Decal_Chunk::AVP_Decal_Chunk(Chunk_With_Children* parent,const char* data,si int loaded_decal_size=*(int*)data; data+=4; - decal_size=max(loaded_decal_size,(int)sizeof(AVP_Decal)); + decal_size=std::max(loaded_decal_size,(int)sizeof(AVP_Decal)); //allocate buffer for decals , and initialise to zero decal_buffer=new char[num_decals*decal_size]; diff --git a/src/avp/win95/objsetup.cpp b/src/avp/win95/objsetup.cpp index bf3cddf..d467631 100644 --- a/src/avp/win95/objsetup.cpp +++ b/src/avp/win95/objsetup.cpp @@ -1,5 +1,6 @@ #define DB_LEVEL 1 +#include #include #include "list_tem.hpp" @@ -956,7 +957,7 @@ void add_placed_hierarchy(Placed_Hierarchy_Chunk* phc,const char* fname,const ch for(; !chlif.done(); chlif.next()) { Indexed_Sound_Chunk* isc=(Indexed_Sound_Chunk*)chlif(); - phtt->num_sounds=max(phtt->num_sounds,isc->index+1); + phtt->num_sounds=std::max(phtt->num_sounds,isc->index+1); } if(phtt->num_sounds) @@ -990,7 +991,7 @@ void add_placed_hierarchy(Placed_Hierarchy_Chunk* phc,const char* fname,const ch for(chlif.restart();!chlif.done();chlif.next()) { Placed_Hierarchy_Sequence_Chunk* phsc=(Placed_Hierarchy_Sequence_Chunk*)chlif(); - phtt->num_sequences=max(phtt->num_sequences,phsc->index+1); + phtt->num_sequences=std::max(phtt->num_sequences,phsc->index+1); } GLOBALASSERT(phtt->num_sequences); @@ -1777,11 +1778,11 @@ static void add_placed_light(Object_Chunk* ob,int list_pos,AVP_Strategy_Chunk* a pltd->colour_diff_green-=pltd->colour_green; pltd->colour_diff_blue-=pltd->colour_blue; - pltd->fade_up_time=(max(lchunk->light.fade_up_time,1)*ONE_FIXED)/1000; - pltd->fade_down_time=(max(lchunk->light.fade_down_time,1)*ONE_FIXED)/1000; - pltd->up_time=(max(lchunk->light.up_time,1)*ONE_FIXED)/1000; - pltd->down_time=(max(lchunk->light.down_time,1)*ONE_FIXED)/1000; - pltd->timer=(max(lchunk->light.start_time,1)*ONE_FIXED)/1000; + pltd->fade_up_time=(std::max(lchunk->light.fade_up_time,1)*ONE_FIXED)/1000; + pltd->fade_down_time=(std::max(lchunk->light.fade_down_time,1)*ONE_FIXED)/1000; + pltd->up_time=(std::max(lchunk->light.up_time,1)*ONE_FIXED)/1000; + pltd->down_time=(std::max(lchunk->light.down_time,1)*ONE_FIXED)/1000; + pltd->timer=(std::max(lchunk->light.start_time,1)*ONE_FIXED)/1000; pltd->type=(LIGHT_TYPE)lchunk->light.light_type; pltd->on_off_type=(LIGHT_ON_OFF_TYPE)lchunk->light.on_off_type; @@ -3808,7 +3809,7 @@ void setup_particle_generators(Environment_Data_Chunk * envd) if(data_chunk->type==PARGEN_TYPE_SPARK) part_temp->frequency=(data_chunk->time*ONE_FIXED)/10; else - part_temp->frequency=ONE_FIXED/max(data_chunk->quantity,1); + part_temp->frequency=ONE_FIXED/std::max(data_chunk->quantity,static_cast(1)); part_temp->active=!(data_chunk->flags & ParticleGeneratorFlag_Inactive); diff --git a/src/avp/win95/projload.cpp b/src/avp/win95/projload.cpp index 47a2e61..50082f7 100644 --- a/src/avp/win95/projload.cpp +++ b/src/avp/win95/projload.cpp @@ -1,5 +1,7 @@ #define DB_LEVEL 2 +#include + #include "3dc.h" #include "inline.h" #include "module.h" @@ -167,7 +169,7 @@ void setup_paths(RIFFHANDLE h) for(; !plif.done(); plif.next()) { AVP_Path_Chunk* apc=(AVP_Path_Chunk*) plif(); - PathArraySize=max(PathArraySize,apc->PathID+1); + PathArraySize=std::max(PathArraySize,apc->PathID+1); } PathArray=(PATHHEADER*)PoolAllocateMem(sizeof(PATHHEADER)*PathArraySize); @@ -187,7 +189,7 @@ void setup_paths(RIFFHANDLE h) int length=apc->PathLength; if(apc->flags & PathFlag_BackAndForth) { - length=max(length,(length-1)*2); + length=std::max(length,(length-1)*2); } path->modules_in_path=(AIMODULE**)PoolAllocateMem(sizeof(AIMODULE*)*length); @@ -463,7 +465,7 @@ Global_Hierarchy_Store::Global_Hierarchy_Store (RIFFHANDLE h) for(; !chlif.done(); chlif.next()) { Indexed_Sound_Chunk* isc=(Indexed_Sound_Chunk*)chlif(); - max_index=max(max_index,isc->index); + max_index=std::max(max_index,isc->index); } //now create a large enough array , and fill it in num_sounds=max_index+1; @@ -716,7 +718,7 @@ void Global_Hierarchy_Store::setup_alternate_shape_sets(List Set_Collection_Num); + max_index=std::max(max_index,coll->Set_Collection_Num); } if(max_index==-1) return; @@ -988,11 +990,11 @@ SECTION * Global_Hierarchy_Store::build_hierarchy (Object_Hierarchy_Chunk * ohc, if (frame_nonum_frames) { //calculate sequence length , making sure it doesn't overflow an unsigned short - kfd->Sequence_Length =(unsigned short) min(seq->frames[frame_no].at_frame_no - this_frame_no,65535); + kfd->Sequence_Length =(unsigned short) std::min(seq->frames[frame_no].at_frame_no - this_frame_no,65535); } else { - kfd->Sequence_Length =(unsigned short) min(65536 - this_frame_no,65535); + kfd->Sequence_Length =(unsigned short) std::min(65536 - this_frame_no,65535); } } @@ -1196,11 +1198,11 @@ SECTION * Global_Hierarchy_Store::build_hierarchy (Object_Hierarchy_Chunk * ohc, if (frame_noSequence_Length =(unsigned short) min(frame_array[frame_no]->at_frame_no - this_frame_no,65535); + kfd->Sequence_Length =(unsigned short) std::min(frame_array[frame_no]->at_frame_no - this_frame_no,65535L); } else { - kfd->Sequence_Length =(unsigned short) min(65536 - this_frame_no , 65535); + kfd->Sequence_Length =(unsigned short) std::min(65536 - this_frame_no , 65535); } } //sort out some settings for the last frame diff --git a/src/fixer.h b/src/fixer.h index fff20c3..e239584 100644 --- a/src/fixer.h +++ b/src/fixer.h @@ -47,6 +47,7 @@ extern "C" { #define PACKED __attribute__((packed)) /* windows junk */ +#ifndef __cplusplus #ifndef min #define min(a, b) (((a) < (b)) ? (a) : (b)) #endif @@ -54,6 +55,7 @@ extern "C" { #ifndef max #define max(a, b) (((a) > (b)) ? (a) : (b)) #endif +#endif #define __cdecl 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 #include #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 #include #include #include @@ -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 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(LIFchlif(&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 #include #include "chnktype.hpp" @@ -1044,17 +1045,17 @@ void ChunkAnimSequence::UpdateNormalsAndExtents(ChunkShape const * cs,List* for (int j=0; jnum_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 + #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 + #include "chunk.hpp" #include "chnktype.hpp" #include "mishchnk.hpp" @@ -625,7 +627,7 @@ void File_Chunk::post_input_processing() LIF 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 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 #include #include "unaligned.h" #include "chunk.hpp" @@ -191,17 +192,17 @@ void Shape_Chunk::post_input_processing() for (int i=0; inum_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())