From 0dd91ceda2583a1a03fdef5aa404128bf7dc5cfc Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 27 Oct 2019 22:26:57 +0300 Subject: [PATCH 01/19] xash3d-fwgs: append missing new line at the end of file --- common/beamdef.h | 2 +- common/boneinfo.h | 2 +- common/bspfile.h | 2 +- common/cl_entity.h | 2 +- common/con_nprint.h | 2 +- common/demo_api.h | 2 +- common/dlight.h | 2 +- common/enginefeatures.h | 2 +- common/entity_types.h | 2 +- common/event_api.h | 2 +- common/event_args.h | 2 +- common/event_flags.h | 2 +- common/gameinfo.h | 2 +- common/hltv.h | 2 +- common/ivoicetweak.h | 2 +- common/kbutton.h | 2 +- common/lightstyle.h | 2 +- common/netadr.h | 2 +- common/particledef.h | 2 +- common/pmtrace.h | 2 +- common/qfont.h | 2 +- common/ref_params.h | 2 +- common/screenfade.h | 2 +- common/studio_event.h | 2 +- common/usercmd.h | 2 +- common/wadfile.h | 2 +- common/weaponinfo.h | 2 +- common/wrect.h | 2 +- engine/alias.h | 2 +- engine/client/s_load.c | 2 +- engine/common/imagelib/img_quant.c | 2 +- engine/common/pm_local.h | 2 +- engine/common/soundlib/libmpg/dct36.c | 2 +- engine/common/soundlib/libmpg/dct64.c | 2 +- engine/common/soundlib/libmpg/fmt123.h | 2 +- engine/common/soundlib/libmpg/getbits.h | 2 +- engine/common/soundlib/libmpg/huffman.h | 2 +- engine/common/soundlib/libmpg/index.c | 2 +- engine/common/soundlib/libmpg/index.h | 2 +- engine/common/soundlib/libmpg/layer3.c | 2 +- engine/common/soundlib/libmpg/mpeghead.h | 2 +- engine/common/soundlib/libmpg/parse.c | 2 +- engine/common/soundlib/libmpg/reader.h | 2 +- engine/common/soundlib/libmpg/synth.h | 2 +- engine/common/soundlib/libmpg/tabinit.c | 2 +- engine/custom.h | 2 +- engine/customentity.h | 2 +- engine/edict.h | 2 +- engine/progdefs.h | 2 +- engine/shake.h | 2 +- engine/sprite.h | 2 +- mainui | 2 +- pm_shared/pm_info.h | 2 +- ref_gl/gl_frustum.h | 2 +- 54 files changed, 54 insertions(+), 54 deletions(-) diff --git a/common/beamdef.h b/common/beamdef.h index 3b8c553a..1dc271f8 100644 --- a/common/beamdef.h +++ b/common/beamdef.h @@ -57,4 +57,4 @@ struct beam_s struct particle_s *particles; }; -#endif//BEAMDEF_H \ No newline at end of file +#endif//BEAMDEF_H diff --git a/common/boneinfo.h b/common/boneinfo.h index bd58845e..1c88d7e1 100644 --- a/common/boneinfo.h +++ b/common/boneinfo.h @@ -22,4 +22,4 @@ typedef struct vec3_t origin; } boneinfo_t; -#endif//BONEINFO_H \ No newline at end of file +#endif//BONEINFO_H diff --git a/common/bspfile.h b/common/bspfile.h index d8b47134..dbc3dadb 100644 --- a/common/bspfile.h +++ b/common/bspfile.h @@ -321,4 +321,4 @@ typedef struct int lightofs; // start of [numstyles*surfsize] samples } dface32_t; -#endif//BSPFILE_H \ No newline at end of file +#endif//BSPFILE_H diff --git a/common/cl_entity.h b/common/cl_entity.h index 02f84e35..6235a0a3 100644 --- a/common/cl_entity.h +++ b/common/cl_entity.h @@ -102,4 +102,4 @@ struct cl_entity_s colorVec cvFloorColor; }; -#endif//CL_ENTITY_H \ No newline at end of file +#endif//CL_ENTITY_H diff --git a/common/con_nprint.h b/common/con_nprint.h index 5d87c760..96582776 100644 --- a/common/con_nprint.h +++ b/common/con_nprint.h @@ -22,4 +22,4 @@ typedef struct con_nprint_s float color[3]; // RGB colors ( 0.0 -> 1.0 scale ) } con_nprint_t; -#endif//CON_NPRINT_H \ No newline at end of file +#endif//CON_NPRINT_H diff --git a/common/demo_api.h b/common/demo_api.h index fa89bbef..3e3c6556 100644 --- a/common/demo_api.h +++ b/common/demo_api.h @@ -24,4 +24,4 @@ typedef struct demo_api_s void (*WriteBuffer)( int size, unsigned char *buffer ); } demo_api_t; -#endif//DEMO_API_H \ No newline at end of file +#endif//DEMO_API_H diff --git a/common/dlight.h b/common/dlight.h index b139d582..b8a520b3 100644 --- a/common/dlight.h +++ b/common/dlight.h @@ -28,4 +28,4 @@ typedef struct dlight_s qboolean dark; // subtracts light instead of adding } dlight_t; -#endif//DLIGHT_H \ No newline at end of file +#endif//DLIGHT_H diff --git a/common/enginefeatures.h b/common/enginefeatures.h index d1e90ba2..1739c956 100644 --- a/common/enginefeatures.h +++ b/common/enginefeatures.h @@ -26,4 +26,4 @@ GNU General Public License for more details. #define ENGINE_IMPROVED_LINETRACE (1<<6) // new traceline that tracing through alphatextures #define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine -#endif//FEATURES_H \ No newline at end of file +#endif//FEATURES_H diff --git a/common/entity_types.h b/common/entity_types.h index 25a8fce9..32b501b8 100644 --- a/common/entity_types.h +++ b/common/entity_types.h @@ -22,4 +22,4 @@ #define ET_BEAM 3 #define ET_FRAGMENTED 4 // BMODEL or SPRITE that was split across BSP nodes -#endif//ENTITY_TYPES_H \ No newline at end of file +#endif//ENTITY_TYPES_H diff --git a/common/event_api.h b/common/event_api.h index 699310d0..8b7ae640 100644 --- a/common/event_api.h +++ b/common/event_api.h @@ -55,4 +55,4 @@ typedef struct event_api_s void ( *EV_PopTraceBounds)( void ); } event_api_t; -#endif//EVENT_API_H \ No newline at end of file +#endif//EVENT_API_H diff --git a/common/event_args.h b/common/event_args.h index d85906cc..b4be77f4 100644 --- a/common/event_args.h +++ b/common/event_args.h @@ -44,4 +44,4 @@ typedef struct event_args_s int bparam2; } event_args_t; -#endif//EVENT_ARGS_H \ No newline at end of file +#endif//EVENT_ARGS_H diff --git a/common/event_flags.h b/common/event_flags.h index 3c1d8fb3..d10ddace 100644 --- a/common/event_flags.h +++ b/common/event_flags.h @@ -42,4 +42,4 @@ // Only issue event client side ( from shared code ) #define FEV_CLIENT (1<<6) -#endif//EVENT_FLAGS_H \ No newline at end of file +#endif//EVENT_FLAGS_H diff --git a/common/gameinfo.h b/common/gameinfo.h index aacc74d3..597ec1fb 100644 --- a/common/gameinfo.h +++ b/common/gameinfo.h @@ -47,4 +47,4 @@ typedef struct int gamemode; } GAMEINFO; -#endif//GAMEINFO_H \ No newline at end of file +#endif//GAMEINFO_H diff --git a/common/hltv.h b/common/hltv.h index 79251910..60adb020 100644 --- a/common/hltv.h +++ b/common/hltv.h @@ -56,4 +56,4 @@ #define MAX_DIRECTOR_CMD_PARAMETERS 4 #define MAX_DIRECTOR_CMD_STRING 128 -#endif//HLTV_H \ No newline at end of file +#endif//HLTV_H diff --git a/common/ivoicetweak.h b/common/ivoicetweak.h index 2f95d515..e7802855 100644 --- a/common/ivoicetweak.h +++ b/common/ivoicetweak.h @@ -35,4 +35,4 @@ typedef struct IVoiceTweak_s float (*GetControlFloat)( VoiceTweakControl iControl ); } IVoiceTweak; -#endif//IVOICETWEAK_H \ No newline at end of file +#endif//IVOICETWEAK_H diff --git a/common/kbutton.h b/common/kbutton.h index 23cd8acc..820e2d9b 100644 --- a/common/kbutton.h +++ b/common/kbutton.h @@ -15,4 +15,4 @@ typedef struct kbutton_s int state; // low bit is down state } kbutton_t; -#endif // !KBUTTONH \ No newline at end of file +#endif // !KBUTTONH diff --git a/common/lightstyle.h b/common/lightstyle.h index 8b42edac..a695e981 100644 --- a/common/lightstyle.h +++ b/common/lightstyle.h @@ -26,4 +26,4 @@ typedef struct float time; // local time is gurantee what new style begins from the start, not mid or end of the sequence } lightstyle_t; -#endif//LIGHTSTYLE_H \ No newline at end of file +#endif//LIGHTSTYLE_H diff --git a/common/netadr.h b/common/netadr.h index dfeea8b0..21075819 100644 --- a/common/netadr.h +++ b/common/netadr.h @@ -34,4 +34,4 @@ typedef struct netadr_s unsigned short port; } netadr_t; -#endif//NETADR_H \ No newline at end of file +#endif//NETADR_H diff --git a/common/particledef.h b/common/particledef.h index 959c960b..700815c0 100644 --- a/common/particledef.h +++ b/common/particledef.h @@ -50,4 +50,4 @@ typedef struct particle_s unsigned char context; } particle_t; -#endif//PARTICLEDEF_H \ No newline at end of file +#endif//PARTICLEDEF_H diff --git a/common/pmtrace.h b/common/pmtrace.h index 6394de56..89995d10 100644 --- a/common/pmtrace.h +++ b/common/pmtrace.h @@ -38,4 +38,4 @@ struct pmtrace_s int hitgroup; }; -#endif//PM_TRACE_H \ No newline at end of file +#endif//PM_TRACE_H diff --git a/common/qfont.h b/common/qfont.h index 06408572..468ee134 100644 --- a/common/qfont.h +++ b/common/qfont.h @@ -35,4 +35,4 @@ typedef struct qfont_s byte data[4]; } qfont_t; -#endif//QFONT_H \ No newline at end of file +#endif//QFONT_H diff --git a/common/ref_params.h b/common/ref_params.h index 3a0c1859..6a0226dc 100644 --- a/common/ref_params.h +++ b/common/ref_params.h @@ -102,4 +102,4 @@ typedef struct ref_viewpass_s int flags; // if !=0 nothing is drawn by the engine except clientDraw functions } ref_viewpass_t; -#endif//REF_PARAMS_H \ No newline at end of file +#endif//REF_PARAMS_H diff --git a/common/screenfade.h b/common/screenfade.h index 730f729e..e4169251 100644 --- a/common/screenfade.h +++ b/common/screenfade.h @@ -26,4 +26,4 @@ typedef struct screenfade_s int fadeFlags; // Fading flags } screenfade_t; -#endif//SCREENFADE_H \ No newline at end of file +#endif//SCREENFADE_H diff --git a/common/studio_event.h b/common/studio_event.h index 29ea1f90..c94aa708 100644 --- a/common/studio_event.h +++ b/common/studio_event.h @@ -24,4 +24,4 @@ typedef struct mstudioevent_s char options[64]; } mstudioevent_t; -#endif//STUDIO_EVENT_H \ No newline at end of file +#endif//STUDIO_EVENT_H diff --git a/common/usercmd.h b/common/usercmd.h index 96e3c91b..4420b71f 100644 --- a/common/usercmd.h +++ b/common/usercmd.h @@ -36,4 +36,4 @@ typedef struct usercmd_s vec3_t impact_position; } usercmd_t; -#endif//USERCMD_H \ No newline at end of file +#endif//USERCMD_H diff --git a/common/wadfile.h b/common/wadfile.h index 646153b9..7c02dee8 100644 --- a/common/wadfile.h +++ b/common/wadfile.h @@ -83,4 +83,4 @@ typedef struct mip_s unsigned int offsets[4]; // four mip maps stored } mip_t; -#endif//WADFILE_H \ No newline at end of file +#endif//WADFILE_H diff --git a/common/weaponinfo.h b/common/weaponinfo.h index ae78c645..73a2f8dc 100644 --- a/common/weaponinfo.h +++ b/common/weaponinfo.h @@ -47,4 +47,4 @@ typedef struct weapon_data_s float fuser4; } weapon_data_t; -#endif//WEAPONINFO_H \ No newline at end of file +#endif//WEAPONINFO_H diff --git a/common/wrect.h b/common/wrect.h index 8dd2ba2f..4d15e6f3 100644 --- a/common/wrect.h +++ b/common/wrect.h @@ -21,4 +21,4 @@ typedef struct wrect_s int left, right, top, bottom; } wrect_t; -#endif//WRECT_H \ No newline at end of file +#endif//WRECT_H diff --git a/engine/alias.h b/engine/alias.h index 7c6910ac..29905450 100644 --- a/engine/alias.h +++ b/engine/alias.h @@ -135,4 +135,4 @@ typedef struct aliasskintype_t type; } daliasskintype_t; -#endif//ALIAS_H \ No newline at end of file +#endif//ALIAS_H diff --git a/engine/client/s_load.c b/engine/client/s_load.c index 0cef0550..cb4573bf 100644 --- a/engine/client/s_load.c +++ b/engine/client/s_load.c @@ -407,4 +407,4 @@ void S_FreeSounds( void ) memset( s_sfxHashList, 0, sizeof( s_sfxHashList )); s_numSfx = 0; -} \ No newline at end of file +} diff --git a/engine/common/imagelib/img_quant.c b/engine/common/imagelib/img_quant.c index 92af3809..6ddcee47 100644 --- a/engine/common/imagelib/img_quant.c +++ b/engine/common/imagelib/img_quant.c @@ -468,4 +468,4 @@ rgbdata_t *Image_Quantize( rgbdata_t *pic ) pic->size = image.size; return pic; -} \ No newline at end of file +} diff --git a/engine/common/pm_local.h b/engine/common/pm_local.h index 76f797cf..d73dd375 100644 --- a/engine/common/pm_local.h +++ b/engine/common/pm_local.h @@ -48,4 +48,4 @@ msurface_t *PM_RecursiveSurfCheck( model_t *model, mnode_t *node, vec3_t p1, vec msurface_t *PM_TraceSurface( physent_t *pe, vec3_t start, vec3_t end ); int PM_TestLineExt( playermove_t *pmove, physent_t *ents, int numents, const vec3_t start, const vec3_t end, int flags ); -#endif//PM_LOCAL_H \ No newline at end of file +#endif//PM_LOCAL_H diff --git a/engine/common/soundlib/libmpg/dct36.c b/engine/common/soundlib/libmpg/dct36.c index be71c833..936ed136 100644 --- a/engine/common/soundlib/libmpg/dct36.c +++ b/engine/common/soundlib/libmpg/dct36.c @@ -318,4 +318,4 @@ void dct12( float *in, float *rawout1, float *rawout2, register float *wi, regis out2[0+2] += REAL_MUL(in4, wi[2]); out2[5-2] += REAL_MUL(in4, wi[5-2]); } -} \ No newline at end of file +} diff --git a/engine/common/soundlib/libmpg/dct64.c b/engine/common/soundlib/libmpg/dct64.c index 4e3352df..f4814d31 100644 --- a/engine/common/soundlib/libmpg/dct64.c +++ b/engine/common/soundlib/libmpg/dct64.c @@ -172,4 +172,4 @@ void dct64( float *out0, float *out1, float *samples ) out1[0x10*13] = REAL_SCALE_DCT64( bufs[16+7] + bufs[16+15] ); out1[0x10*14] = REAL_SCALE_DCT64( bufs[15] ); out1[0x10*15] = REAL_SCALE_DCT64( bufs[16+15] ); -} \ No newline at end of file +} diff --git a/engine/common/soundlib/libmpg/fmt123.h b/engine/common/soundlib/libmpg/fmt123.h index d33990f2..1b7f1107 100644 --- a/engine/common/soundlib/libmpg/fmt123.h +++ b/engine/common/soundlib/libmpg/fmt123.h @@ -41,4 +41,4 @@ enum mpg123_enc_enum MPG123_ENC_ALAW_8 = 0x08, }; -#endif//FMT123_H \ No newline at end of file +#endif//FMT123_H diff --git a/engine/common/soundlib/libmpg/getbits.h b/engine/common/soundlib/libmpg/getbits.h index 178e537d..852fa242 100644 --- a/engine/common/soundlib/libmpg/getbits.h +++ b/engine/common/soundlib/libmpg/getbits.h @@ -73,4 +73,4 @@ static uint getbits( mpg123_handle_t *fr, int number_of_bits ) return rval; } -#endif//GETBITS_H \ No newline at end of file +#endif//GETBITS_H diff --git a/engine/common/soundlib/libmpg/huffman.h b/engine/common/soundlib/libmpg/huffman.h index 2fd855dd..446d669c 100644 --- a/engine/common/soundlib/libmpg/huffman.h +++ b/engine/common/soundlib/libmpg/huffman.h @@ -334,4 +334,4 @@ static const struct newhuff htc[] = { 0 , tab_c1 } }; -#endif//HUFFMAN_H \ No newline at end of file +#endif//HUFFMAN_H diff --git a/engine/common/soundlib/libmpg/index.c b/engine/common/soundlib/libmpg/index.c index c3bafa33..fd054652 100644 --- a/engine/common/soundlib/libmpg/index.c +++ b/engine/common/soundlib/libmpg/index.c @@ -152,4 +152,4 @@ void fi_reset( frame_index_t *fi ) fi->fill = 0; fi->step = 1; fi->next = fi_next( fi ); -} \ No newline at end of file +} diff --git a/engine/common/soundlib/libmpg/index.h b/engine/common/soundlib/libmpg/index.h index 200c5a3d..195f8627 100644 --- a/engine/common/soundlib/libmpg/index.h +++ b/engine/common/soundlib/libmpg/index.h @@ -42,4 +42,4 @@ int fi_set( frame_index_t *fi, mpg_off_t *offsets, mpg_off_t step, size_t fill ) // empty the index (setting fill=0 and step=1), but keep current size. void fi_reset( frame_index_t *fi ); -#endif//INDEX_H \ No newline at end of file +#endif//INDEX_H diff --git a/engine/common/soundlib/libmpg/layer3.c b/engine/common/soundlib/libmpg/layer3.c index 1cc40e3c..9a574dde 100644 --- a/engine/common/soundlib/libmpg/layer3.c +++ b/engine/common/soundlib/libmpg/layer3.c @@ -1563,4 +1563,4 @@ int do_layer3( mpg123_handle_t *fr ) } return clip; -} \ No newline at end of file +} diff --git a/engine/common/soundlib/libmpg/mpeghead.h b/engine/common/soundlib/libmpg/mpeghead.h index 8fcb71fe..6b2b4637 100644 --- a/engine/common/soundlib/libmpg/mpeghead.h +++ b/engine/common/soundlib/libmpg/mpeghead.h @@ -60,4 +60,4 @@ GNU General Public License for more details. // a mask for changed sampling rate (version or rate bits). #define HDR_SAMPMASK (HDR_VERSION|HDR_SAMPLERATE) -#endif//MPEGHEAD_H \ No newline at end of file +#endif//MPEGHEAD_H diff --git a/engine/common/soundlib/libmpg/parse.c b/engine/common/soundlib/libmpg/parse.c index 360de077..69bd36d0 100644 --- a/engine/common/soundlib/libmpg/parse.c +++ b/engine/common/soundlib/libmpg/parse.c @@ -1080,4 +1080,4 @@ read_frame_bad: // that return code might be inherited from some feeder action, or reader error. return ret; -} \ No newline at end of file +} diff --git a/engine/common/soundlib/libmpg/reader.h b/engine/common/soundlib/libmpg/reader.h index 6f7af6b3..fc8fc015 100644 --- a/engine/common/soundlib/libmpg/reader.h +++ b/engine/common/soundlib/libmpg/reader.h @@ -128,4 +128,4 @@ mpg_off_t feed_set_pos( mpg123_handle_t *fr, mpg_off_t pos ); // error fallback void open_bad( mpg123_handle_t *fr ); -#endif//READER_H \ No newline at end of file +#endif//READER_H diff --git a/engine/common/soundlib/libmpg/synth.h b/engine/common/soundlib/libmpg/synth.h index 2721a19b..5beabb3e 100644 --- a/engine/common/soundlib/libmpg/synth.h +++ b/engine/common/soundlib/libmpg/synth.h @@ -54,4 +54,4 @@ typedef struct synth_s void init_synth( mpg123_handle_t *fr ); int set_synth_functions( mpg123_handle_t *fr ); -#endif//SYNTH_H \ No newline at end of file +#endif//SYNTH_H diff --git a/engine/common/soundlib/libmpg/tabinit.c b/engine/common/soundlib/libmpg/tabinit.c index 5c678b37..42ea89ed 100644 --- a/engine/common/soundlib/libmpg/tabinit.c +++ b/engine/common/soundlib/libmpg/tabinit.c @@ -99,4 +99,4 @@ void make_decode_tables( mpg123_handle_t *fr ) if( i % 64 == 63 ) scaleval = -scaleval; } -} \ No newline at end of file +} diff --git a/engine/custom.h b/engine/custom.h index aed6d4a1..e8eaab01 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -90,4 +90,4 @@ typedef struct customization_s #define FCUST_WIPEDATA ( 1<<1 ) #define FCUST_IGNOREINIT ( 1<<2 ) -#endif // CUSTOM_H \ No newline at end of file +#endif // CUSTOM_H diff --git a/engine/customentity.h b/engine/customentity.h index dc867e5b..9443da9c 100644 --- a/engine/customentity.h +++ b/engine/customentity.h @@ -36,4 +36,4 @@ enum #define BEAM_FSHADEIN 0x40 #define BEAM_FSHADEOUT 0x80 -#endif//CUSTOMENTITY_H \ No newline at end of file +#endif//CUSTOMENTITY_H diff --git a/engine/edict.h b/engine/edict.h index 30ba0810..820190e1 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -46,4 +46,4 @@ struct edict_s // other fields from progs come immediately after }; -#endif//EDICT_H \ No newline at end of file +#endif//EDICT_H diff --git a/engine/progdefs.h b/engine/progdefs.h index 74004a27..5e540439 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -215,4 +215,4 @@ typedef struct entvars_s edict_t *euser4; } entvars_t; -#endif//PROGDEFS_H \ No newline at end of file +#endif//PROGDEFS_H diff --git a/engine/shake.h b/engine/shake.h index 5a1da46a..b2e88a33 100644 --- a/engine/shake.h +++ b/engine/shake.h @@ -47,4 +47,4 @@ typedef struct byte r, g, b, a; // fade to color ( max alpha ) } ScreenFade; -#endif // SHAKE_H \ No newline at end of file +#endif // SHAKE_H diff --git a/engine/sprite.h b/engine/sprite.h index ba06ece0..a62a14ed 100644 --- a/engine/sprite.h +++ b/engine/sprite.h @@ -125,4 +125,4 @@ typedef struct frametype_t type; } dframetype_t; -#endif//SPRITE_H \ No newline at end of file +#endif//SPRITE_H diff --git a/mainui b/mainui index ccf8c0ff..489fc547 160000 --- a/mainui +++ b/mainui @@ -1 +1 @@ -Subproject commit ccf8c0ff2af94f373d773874a192d2c422f88c37 +Subproject commit 489fc5474ca0ce9afa69b5f7e656da61fd2d2654 diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index ea54e6db..1bb32e46 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -17,4 +17,4 @@ #define MAX_PHYSINFO_STRING 256 -#endif//PM_INFO_H \ No newline at end of file +#endif//PM_INFO_H diff --git a/ref_gl/gl_frustum.h b/ref_gl/gl_frustum.h index 61052434..f48793b5 100644 --- a/ref_gl/gl_frustum.h +++ b/ref_gl/gl_frustum.h @@ -49,4 +49,4 @@ qboolean GL_FrustumCullSphere( gl_frustum_t *out, const vec3_t centre, float rad void GL_FrustumEnablePlane( gl_frustum_t *out, int side ); void GL_FrustumDisablePlane( gl_frustum_t *out, int side ); -#endif//GL_FRUSTUM_H \ No newline at end of file +#endif//GL_FRUSTUM_H From ae35f15f156a995c8edb3fec1e0becc1f68b2314 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 24 Oct 2019 12:42:20 +0300 Subject: [PATCH 02/19] engine: wscript: add option to build against sdl1.2 --- engine/wscript | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/engine/wscript b/engine/wscript index ebc86351..6910e5f3 100644 --- a/engine/wscript +++ b/engine/wscript @@ -12,6 +12,7 @@ def options(opt): grp.add_option('--enable-stdin-input', action = 'store_true', dest = 'USE_SELECT', default = False, help = 'enable console input from stdin (always enabled for dedicated) [default: %default]') + grp.add_option('--fbdev', action = 'store_true', dest = 'FBDEV_SW', default = False, help = 'build fbdev-only software-only engine') grp.add_option('--disable-async-resolve', action = 'store_true', dest = 'NO_ASYNC_RESOLVE', default = False, @@ -19,6 +20,9 @@ def options(opt): grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False, help = 'enable custom swap allocator. For devices with no swap support') + grp.add_option('--enable-legacy-sdl', action = 'store_true', dest = 'SDL12', default = False, + help = 'enable using SDL1.2 instead of SDL2(not recommended) [default: %default') + opt.load('sdl2') def configure(conf): @@ -34,11 +38,15 @@ def configure(conf): conf.define('XASH_FBDEV', 1) conf.check_cc( lib = 'asound' ) conf.check_cc( lib = 'rt' ) + elif conf.options.SDL12: + conf.define('XASH_SDL', 12) + conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' ) + conf.env.HAVE_SDL2 = True else: conf.load('sdl2') if not conf.env.HAVE_SDL2: conf.fatal('SDL2 not availiable! If you want to build dedicated server, specify --dedicated') - conf.define('XASH_SDL', 1) + conf.define('XASH_SDL', 2) if conf.options.USE_SELECT == None: conf.options.USE_SELECT = conf.options.DEDICATED From 8dafbaeda20aa8692b726d6777aad2cb5897dbc9 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 24 Oct 2019 12:43:17 +0300 Subject: [PATCH 03/19] engine: platform: sdl: dirty wip sdl1.2 port --- engine/platform/sdl/events.c | 84 ++++++++++++++++++++++++++++- engine/platform/sdl/in_sdl.c | 29 ++++++++-- engine/platform/sdl/s_sdl.c | 20 ++++++- engine/platform/sdl/vid_sdl.c | 99 +++++++++++++++++++++-------------- 4 files changed, 186 insertions(+), 46 deletions(-) diff --git a/engine/platform/sdl/events.c b/engine/platform/sdl/events.c index 5da4341a..0db9a15b 100644 --- a/engine/platform/sdl/events.c +++ b/engine/platform/sdl/events.c @@ -39,6 +39,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) int keynum = key.keysym.scancode; qboolean numLock = SDL_GetModState() & KMOD_NUM; +#if XASH_SDL == 2 if( SDL_IsTextInputActive() && down ) { if( SDL_GetModState() & KMOD_CTRL ) @@ -52,6 +53,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) return; } } +#endif #define DECLARE_KEY_RANGE( min, max, repl ) \ if( keynum >= (min) && keynum <= (max) ) \ @@ -59,10 +61,10 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) keynum = keynum - (min) + (repl); \ } +#if XASH_SDL == 2 DECLARE_KEY_RANGE( SDL_SCANCODE_A, SDL_SCANCODE_Z, 'a' ) else DECLARE_KEY_RANGE( SDL_SCANCODE_1, SDL_SCANCODE_9, '1' ) else DECLARE_KEY_RANGE( SDL_SCANCODE_F1, SDL_SCANCODE_F12, K_F1 ) -#undef DECLARE_KEY_RANGE else { switch( keynum ) @@ -144,6 +146,86 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) return; } } +#else + DECLARE_KEY_RANGE( SDLK_a, SDLK_z, 'a' ) + else DECLARE_KEY_RANGE( SDLK_1, SDLK_9, '1' ) + else DECLARE_KEY_RANGE( SDLK_F1, SDLK_F12, K_F1 ) + else + { + switch( keynum ) + { + case SDLK_BACKQUOTE: keynum = '`'; break; + case SDLK_0: keynum = '0'; break; + case SDLK_BACKSLASH: keynum = '\\'; break; + case SDLK_LEFTBRACKET: keynum = '['; break; + case SDLK_RIGHTBRACKET: keynum = ']'; break; + case SDLK_EQUALS: keynum = '='; break; + case SDLK_MINUS: keynum = '-'; break; + case SDLK_TAB: keynum = K_TAB; break; + case SDLK_RETURN: keynum = K_ENTER; break; + case SDLK_ESCAPE: keynum = K_ESCAPE; break; + case SDLK_SPACE: keynum = K_SPACE; break; + case SDLK_BACKSPACE: keynum = K_BACKSPACE; break; + case SDLK_UP: keynum = K_UPARROW; break; + case SDLK_LEFT: keynum = K_LEFTARROW; break; + case SDLK_DOWN: keynum = K_DOWNARROW; break; + case SDLK_RIGHT: keynum = K_RIGHTARROW; break; + case SDLK_LALT: + case SDLK_RALT: keynum = K_ALT; break; + case SDLK_LCTRL: + case SDLK_RCTRL: keynum = K_CTRL; break; + case SDLK_LSHIFT: + case SDLK_RSHIFT: keynum = K_SHIFT; break; + case SDLK_LMETA: + case SDLK_RMETA: keynum = K_WIN; break; + case SDLK_INSERT: keynum = K_INS; break; + case SDLK_DELETE: keynum = K_DEL; break; + case SDLK_PAGEDOWN: keynum = K_PGDN; break; + case SDLK_PAGEUP: keynum = K_PGUP; break; + case SDLK_HOME: keynum = K_HOME; break; + case SDLK_END: keynum = K_END; break; + case SDLK_KP1: keynum = numLock ? '1' : K_KP_END; break; + case SDLK_KP2: keynum = numLock ? '2' : K_KP_DOWNARROW; break; + case SDLK_KP3: keynum = numLock ? '3' : K_KP_PGDN; break; + case SDLK_KP4: keynum = numLock ? '4' : K_KP_LEFTARROW; break; + case SDLK_KP5: keynum = numLock ? '5' : K_KP_5; break; + case SDLK_KP6: keynum = numLock ? '6' : K_KP_RIGHTARROW; break; + case SDLK_KP7: keynum = numLock ? '7' : K_KP_HOME; break; + case SDLK_KP8: keynum = numLock ? '8' : K_KP_UPARROW; break; + case SDLK_KP9: keynum = numLock ? '9' : K_KP_PGUP; break; + case SDLK_KP0: keynum = numLock ? '0' : K_KP_INS; break; + case SDLK_KP_PERIOD: keynum = K_KP_DEL; break; + case SDLK_KP_ENTER: keynum = K_KP_ENTER; break; + case SDLK_KP_PLUS: keynum = K_KP_PLUS; break; + case SDLK_KP_MINUS: keynum = K_KP_MINUS; break; + case SDLK_KP_DIVIDE: keynum = K_KP_SLASH; break; + case SDLK_KP_MULTIPLY: keynum = '*'; break; + case SDLK_NUMLOCK: keynum = K_KP_NUMLOCK; break; + case SDLK_CAPSLOCK: keynum = K_CAPSLOCK; break; + case SDLK_SLASH: keynum = '/'; break; + case SDLK_PERIOD: keynum = '.'; break; + case SDLK_SEMICOLON: keynum = ';'; break; + case SDLK_QUOTE: keynum = '\''; break; + case SDLK_COMMA: keynum = ','; break; + case SDLK_PRINT: + { + host.force_draw_version = true; + host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; + break; + } + case SDLK_UNKNOWN: + { + if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown scancode\n" ); + return; + } + default: + if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown key: %s = %i\n", SDL_GetScancodeName( keynum ), keynum ); + return; + } + } +#endif + +#undef DECLARE_KEY_RANGE Key_Event( keynum, down ); } diff --git a/engine/platform/sdl/in_sdl.c b/engine/platform/sdl/in_sdl.c index 3321da04..3486c9be 100644 --- a/engine/platform/sdl/in_sdl.c +++ b/engine/platform/sdl/in_sdl.c @@ -25,7 +25,9 @@ GNU General Public License for more details. #include "vid_common.h" static SDL_Joystick *joy; +#if XASH_SDL == 2 static SDL_GameController *gamecontroller; +#endif // XASH_SDL == 2 /* ============= @@ -46,7 +48,11 @@ Platform_SetMousePos */ void Platform_SetMousePos( int x, int y ) { +#if XASH_SDL == 2 SDL_WarpMouseInWindow( host.hWnd, x, y ); +#else + SDL_WarpMouse( x, y ); +#endif } /* @@ -57,6 +63,7 @@ Platform_GetClipobardText */ void Platform_GetClipboardText( char *buffer, size_t size ) { +#if XASH_SDL == 2 char *sdlbuffer = SDL_GetClipboardText(); if( !sdlbuffer ) @@ -64,6 +71,9 @@ void Platform_GetClipboardText( char *buffer, size_t size ) Q_strncpy( buffer, sdlbuffer, size ); SDL_free( sdlbuffer ); +#else + buffer[0] = 0; +#endif } /* @@ -74,7 +84,9 @@ Platform_SetClipobardText */ void Platform_SetClipboardText( const char *buffer, size_t size ) { +#if XASH_SDL == 2 SDL_SetClipboardText( buffer ); +#endif } /* @@ -96,7 +108,9 @@ SDLash_EnableTextInput */ void Platform_EnableTextInput( qboolean enable ) { +#if XASH_SDL == 2 enable ? SDL_StartTextInput() : SDL_StopTextInput(); +#endif } /* @@ -134,8 +148,10 @@ static int SDLash_JoyInit_Old( int numjoy ) return 0; } +#if XASH_SDL == 2 for( i = 0; i < num; i++ ) Con_Reportf( "%i\t: %s\n", i, SDL_JoystickNameForIndex( i ) ); +#endif Con_Reportf( "Pass +set joy_index N to command line, where N is number, to select active joystick\n" ); @@ -147,6 +163,7 @@ static int SDLash_JoyInit_Old( int numjoy ) return 0; } +#if XASH_SDL == 2 Con_Reportf( "Selected joystick: %s\n" "\tAxes: %i\n" "\tHats: %i\n" @@ -156,11 +173,13 @@ static int SDLash_JoyInit_Old( int numjoy ) SDL_JoystickNumButtons( joy ), SDL_JoystickNumBalls( joy ) ); SDL_GameControllerEventState( SDL_DISABLE ); +#endif SDL_JoystickEventState( SDL_ENABLE ); return num; } +#if XASH_SDL == 2 /* ============= SDLash_JoyInit_New @@ -231,6 +250,7 @@ static int SDLash_JoyInit_New( int numjoy ) return num; } +#endif // XASH_SDL == 2 /* ============= @@ -240,12 +260,13 @@ Platform_JoyInit */ int Platform_JoyInit( int numjoy ) { +#if XASH_SDL == 2 // SDL_Joystick is now an old API // SDL_GameController is preferred - if( Sys_CheckParm( "-sdl_joy_old_api" ) ) - return SDLash_JoyInit_Old(numjoy); - - return SDLash_JoyInit_New(numjoy); + if( !Sys_CheckParm( "-sdl_joy_old_api" ) ) + return SDLash_JoyInit_New(numjoy); +#endif // XASH_SDL == 2 + return SDLash_JoyInit_Old(numjoy); } #endif // XASH_DEDICATED diff --git a/engine/platform/sdl/s_sdl.c b/engine/platform/sdl/s_sdl.c index 8c5a3551..3a3497c5 100644 --- a/engine/platform/sdl/s_sdl.c +++ b/engine/platform/sdl/s_sdl.c @@ -76,8 +76,10 @@ qboolean SNDDMA_Init( void ) // even if we don't have PA // we still can safely set env variables +#if XASH_SDL == 2 SDL_setenv( "PULSE_PROP_application.name", GI->title, 1 ); SDL_setenv( "PULSE_PROP_media.role", "game", 1 ); +#endif memset( &desired, 0, sizeof( desired ) ); desired.freq = SOUND_DMA_SPEED; @@ -86,7 +88,10 @@ qboolean SNDDMA_Init( void ) desired.channels = 2; desired.callback = SDL_SoundCallback; +#if XASH_SDL == 2 sdl_dev = SDL_OpenAudioDevice( NULL, 0, &desired, &obtained, 0 ); +#endif + sdl_dev = SDL_OpenAudio( &desired, &obtained ); if( !sdl_dev ) { @@ -116,9 +121,13 @@ qboolean SNDDMA_Init( void ) dma.buffer = Z_Malloc( dma.samples * 2 ); dma.samplepos = 0; +#if XASH_SDL == 2 Con_Printf( "Using SDL audio driver: %s @ %d Hz\n", SDL_GetCurrentAudioDriver( ), obtained.freq ); +#else + Con_Printf( "Using SDL audio driver @ %d Hz\n", obtained.freq ); +#endif - SDL_PauseAudioDevice( sdl_dev, 0 ); + SNDDMA_Activate( true ); dma.initialized = true; return true; @@ -218,9 +227,12 @@ void SNDDMA_Shutdown( void ) if( sdl_dev ) { - SDL_PauseAudioDevice( sdl_dev, 1 ); + SNDDMA_Activate( false ); + #ifndef __EMSCRIPTEN__ +#if XASH_SDL == 2 SDL_CloseAudioDevice( sdl_dev ); +#endif SDL_CloseAudio( ); #endif } @@ -247,6 +259,10 @@ between a deactivate and an activate. */ void SNDDMA_Activate( qboolean active ) { +#if XASH_SDL == 2 SDL_PauseAudioDevice( sdl_dev, !active ); +#else + SDL_PauseAudio( !active ); +#endif } #endif // XASH_SOUND == SOUND_SDL diff --git a/engine/platform/sdl/vid_sdl.c b/engine/platform/sdl/vid_sdl.c index 7816a38e..45205462 100644 --- a/engine/platform/sdl/vid_sdl.c +++ b/engine/platform/sdl/vid_sdl.c @@ -31,8 +31,10 @@ struct struct { +#if XASH_SDL == 2 SDL_Renderer *renderer; SDL_Texture *tex; +#endif int width, height; SDL_Surface *surf; SDL_Surface *win; @@ -43,6 +45,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * sw.width = width; sw.height = height; +#if XASH_SDL == 2 if( sw.renderer ) { unsigned int format = SDL_GetWindowPixelFormat( host.hWnd ); @@ -110,10 +113,16 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * sw.renderer = NULL; } } +#endif +#if XASH_SDL == 2 if( !sw.renderer ) { sw.win = SDL_GetWindowSurface( host.hWnd ); +#else + { + sw.win = SDL_GetVideoSurface(); +#endif // sdl will create renderer if hw framebuffer unavailiable, so cannot fallback here // if it is failed, it is not possible to draw with SDL in REF_SOFTWARE mode @@ -145,6 +154,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * void *SW_LockBuffer( void ) { +#if XASH_SDL == 2 if( sw.renderer ) { void *pixels; @@ -154,35 +164,38 @@ void *SW_LockBuffer( void ) Sys_Error("%s", SDL_GetError()); return pixels; } - else + + // ensure it not changed (do we really need this?) + sw.win = SDL_GetWindowSurface( host.hWnd ); + //if( !sw.win ) + //SDL_GetWindowSurface( host.hWnd ); +#else + sw.win = SDL_GetVideoSurface(); +#endif + + // prevent buffer overrun + if( !sw.win || sw.win->w < sw.width || sw.win->h < sw.height ) + return NULL; + +#if XASH_SDL == 2 + if( sw.surf ) { - // ensure it not changed (do we really need this?) - sw.win = SDL_GetWindowSurface( host.hWnd ); - - //if( !sw.win ) - //SDL_GetWindowSurface( host.hWnd ); - - // prevent buffer overrun - if( !sw.win || sw.win->w < sw.width || sw.win->h < sw.height ) - return NULL; - - if( sw.surf ) - { - SDL_LockSurface( sw.surf ); - return sw.surf->pixels; - } - else - { - // real window pixels (x11 shm region, dma buffer, etc) - // or SDL_Renderer texture if not supported - SDL_LockSurface( sw.win ); - return sw.win->pixels; - } + SDL_LockSurface( sw.surf ); + return sw.surf->pixels; + } + else +#endif + { + // real window pixels (x11 shm region, dma buffer, etc) + // or SDL_Renderer texture if not supported + SDL_LockSurface( sw.win ); + return sw.win->pixels; } } void SW_UnlockBuffer( void ) { +#if XASH_SDL == 2 if( sw.renderer ) { SDL_Rect src, dst; @@ -197,26 +210,31 @@ void SW_UnlockBuffer( void ) SDL_RenderCopy(sw.renderer, sw.tex, &src, &dst); SDL_RenderPresent(sw.renderer); + + return; //Con_Printf("%s\n", SDL_GetError()); } - else - { - // blit if blitting surface availiable - if( sw.surf ) - { - SDL_Rect src, dst; - src.x = src.y = 0; - src.w = sw.width; - src.h = sw.height; - dst = src; - SDL_UnlockSurface( sw.surf ); - SDL_BlitSurface( sw.surf, &src, sw.win, &dst ); - } - else // already blitted - SDL_UnlockSurface( sw.win ); - SDL_UpdateWindowSurface( host.hWnd ); + // blit if blitting surface availiable + if( sw.surf ) + { + SDL_Rect src, dst; + src.x = src.y = 0; + src.w = sw.width; + src.h = sw.height; + dst = src; + SDL_UnlockSurface( sw.surf ); + SDL_BlitSurface( sw.surf, &src, sw.win, &dst ); + return; } +#endif + + // already blitted + SDL_UnlockSurface( sw.win ); + +#if XASH_SDL == 2 + SDL_UpdateWindowSurface( host.hWnd ); +#endif } int R_MaxVideoModes( void ) @@ -236,6 +254,7 @@ vidmode_t *R_GetVideoMode( int num ) static void R_InitVideoModes( void ) { +#if XASH_SDL == 2 int displayIndex = 0; // TODO: handle multiple displays somehow int i, modes; @@ -280,6 +299,8 @@ static void R_InitVideoModes( void ) num_vidmodes++; } +#else + int i; } static void R_FreeVideoModes( void ) From 9e99a2bc37e3100b2a008cc6b5513524cdd5818d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 24 Oct 2019 12:44:18 +0300 Subject: [PATCH 04/19] engine: dirty sdl1.2 port --- common/defaults.h | 15 ++++++++++----- engine/client/cl_game.c | 4 ++-- engine/client/cl_main.c | 2 +- engine/client/input.c | 8 ++++---- engine/client/vgui/vgui_draw.c | 4 ++-- engine/common/host.c | 14 ++++++++++---- engine/common/system.c | 2 +- 7 files changed, 30 insertions(+), 19 deletions(-) diff --git a/common/defaults.h b/common/defaults.h index d2d58a4b..2848d879 100644 --- a/common/defaults.h +++ b/common/defaults.h @@ -27,17 +27,22 @@ SETUP BACKENDS DEFINITIONS */ #ifndef XASH_DEDICATED - #ifdef XASH_SDL + #if XASH_SDL == 2 + #ifndef XASH_TIMER + #define XASH_TIMER TIMER_SDL + #endif + #else + #ifndef XASH_TIMER + #define XASH_TIMER TIMER_LINUX + #endif + #endif + #ifdef XASH_SDL // by default, use SDL subsystems #ifndef XASH_VIDEO #define XASH_VIDEO VIDEO_SDL #endif // XASH_VIDEO - #ifndef XASH_TIMER - #define XASH_TIMER TIMER_SDL - #endif - #ifndef XASH_INPUT #define XASH_INPUT INPUT_SDL #endif diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 8ffa78e0..fb49bc6c 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -1988,7 +1988,7 @@ static int pfnGetWindowCenterX( void ) } #endif -#ifdef XASH_SDL +#if XASH_SDL == 2 SDL_GetWindowPosition( host.hWnd, &x, NULL ); #endif @@ -2013,7 +2013,7 @@ static int pfnGetWindowCenterY( void ) } #endif -#ifdef XASH_SDL +#if XASH_SDL == 2 SDL_GetWindowPosition( host.hWnd, NULL, &y ); #endif diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 667d0b90..c97ee1f9 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1938,7 +1938,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) return; } -#ifdef XASH_SDL +#if XASH_SDL == 2 SDL_ShowWindow( host.hWnd ); #endif args = MSG_ReadString( msg ); diff --git a/engine/client/input.c b/engine/client/input.c index 01c7fd8a..1e0c87d9 100644 --- a/engine/client/input.c +++ b/engine/client/input.c @@ -194,7 +194,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) else if( newstate == key_game ) { // reset mouse pos, so cancel effect in game -#ifdef XASH_SDL +#if XASH_SDL == 2 if( CVAR_TO_BOOL(touch_enable) ) { SDL_SetRelativeMouseMode( SDL_FALSE ); @@ -214,7 +214,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) if( ( newstate == key_menu || newstate == key_console || newstate == key_message ) && ( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( ))) { -#ifdef XASH_SDL +#if XASH_SDL == 2 SDL_SetWindowGrab(host.hWnd, SDL_FALSE); if( clgame.dllFuncs.pfnLookEvent ) SDL_SetRelativeMouseMode( SDL_FALSE ); @@ -316,7 +316,7 @@ void IN_DeactivateMouse( void ) } in_mouseactive = false; -#ifdef XASH_SDL +#if XASH_SDL == 2 SDL_SetWindowGrab( host.hWnd, SDL_FALSE ); #endif } @@ -416,7 +416,7 @@ void IN_MouseEvent( void ) } else { -#if defined(XASH_SDL) && !defined(_WIN32) +#if XASH_SDL == 2 && !defined(_WIN32) SDL_SetRelativeMouseMode( SDL_FALSE ); SDL_ShowCursor( SDL_TRUE ); #endif diff --git a/engine/client/vgui/vgui_draw.c b/engine/client/vgui/vgui_draw.c index c8e25a56..79cc0bab 100644 --- a/engine/client/vgui/vgui_draw.c +++ b/engine/client/vgui/vgui_draw.c @@ -72,7 +72,7 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y ) void VGUI_InitCursors( void ) { // load up all default cursors -#ifdef XASH_SDL +#if XASH_SDL == 2 s_pDefaultCursor[dc_none] = NULL; s_pDefaultCursor[dc_arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); s_pDefaultCursor[dc_ibeam] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); @@ -108,7 +108,7 @@ void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor ) break; } -#ifdef XASH_SDL +#if XASH_SDL == 2 /// TODO: platform cursors if( CVAR_TO_BOOL( touch_emulate ) ) diff --git a/engine/common/host.c b/engine/common/host.c index e9a437b4..b7449670 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -323,7 +323,7 @@ void Host_MemStats_f( void ) void Host_Minimize_f( void ) { -#ifdef XASH_SDL +#if XASH_SDL == 2 if( host.hWnd ) SDL_MinimizeWindow( host.hWnd ); #endif } @@ -733,7 +733,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha #if TARGET_OS_IOS const char *IOS_GetDocsDir(); Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof(host.rootdir) ); -#elif defined(XASH_SDL) +#elif XASH_SDL == 2 char *szBasePath; if( !( szBasePath = SDL_GetBasePath() ) ) @@ -817,15 +817,21 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha // should work even if it failed SDL_Init( SDL_INIT_TIMER ); +#ifndef SDL_INIT_EVENTS +#define SDL_INIT_EVENTS 0 +#endif + if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) ) { Sys_Warn( "SDL_Init failed: %s", SDL_GetError() ); host.type = HOST_DEDICATED; } - SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); +#if XASH_SDL == 2 + SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); SDL_StopTextInput(); -#endif +#endif // XASH_SDL == 2 +#endif // XASH_SDL if ( !host.rootdir[0] || SetCurrentDirectory( host.rootdir ) != 0) Con_Reportf( "%s is working directory now\n", host.rootdir ); diff --git a/engine/common/system.c b/engine/common/system.c index 1b1a3bd8..d3fe3572 100644 --- a/engine/common/system.c +++ b/engine/common/system.c @@ -426,7 +426,7 @@ void Sys_Error( const char *error, ... ) if( !Host_IsDedicated() ) { -#ifdef XASH_SDL +#if XASH_SDL == 2 if( host.hWnd ) SDL_HideWindow( host.hWnd ); #endif } From 4d5e7c05577176b3c0d73e6d88faec5d8b7b56e6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 25 Oct 2019 17:11:27 +0300 Subject: [PATCH 05/19] platform: minify changes, use SDL_VERSION_ATLEAST macro(left unfinished) --- engine/platform/sdl/events.c | 71 +++++++++++++++++++++++++++++++++-- engine/platform/sdl/in_sdl.c | 46 +++++++++++------------ engine/platform/sdl/s_sdl.c | 25 +++++------- engine/platform/sdl/vid_sdl.c | 46 +++++++++++++---------- 4 files changed, 127 insertions(+), 61 deletions(-) diff --git a/engine/platform/sdl/events.c b/engine/platform/sdl/events.c index 0db9a15b..e888b86f 100644 --- a/engine/platform/sdl/events.c +++ b/engine/platform/sdl/events.c @@ -27,6 +27,70 @@ GNU General Public License for more details. static int wheelbutton; +#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) +#define SDL_SCANCODE_A SDLK_a +#define SDL_SCANCODE_Z SDLK_z +#define SDL_SCANCODE_1 SDLK_1 +#define SDL_SCANCODE_9 SDLK_9 +#define SDL_SCANCODE_F1 SDLK_F1 +#define SDL_SCANCODE_F12 SDLK_F12 +#define SDL_SCANCODE_GRAVE SDLK_BACKQUOTE +#define SDL_SCANCODE_0 SDLK_0 +#define SDL_SCANCODE_BACKSLASH SDLK_BACKSLASH +#define SDL_SCANCODE_LEFTBRACKET SDLK_LEFTBRACKET +#define SDL_SCANCODE_RIGHTBRACKET SDLK_RIGHTBRACKET +#define SDL_SCANCODE_EQUALS: keynum = '='; break; +#define SDL_SCANCODE_MINUS: keynum = '-'; break; +#define SDL_SCANCODE_TAB: keynum = K_TAB; break; +#define SDL_SCANCODE_RETURN: keynum = K_ENTER; break; +#define SDL_SCANCODE_ESCAPE: keynum = K_ESCAPE; break; +#define SDL_SCANCODE_SPACE: keynum = K_SPACE; break; +#define SDL_SCANCODE_BACKSPACE: keynum = K_BACKSPACE; break; +#define SDL_SCANCODE_UP: keynum = K_UPARROW; break; +#define SDL_SCANCODE_LEFT: keynum = K_LEFTARROW; break; +#define SDL_SCANCODE_DOWN: keynum = K_DOWNARROW; break; +#define SDL_SCANCODE_RIGHT: keynum = K_RIGHTARROW; break; +#define SDL_SCANCODE_LALT: +#define SDL_SCANCODE_RALT: keynum = K_ALT; break; +#define SDL_SCANCODE_LCTRL: +#define SDL_SCANCODE_RCTRL: keynum = K_CTRL; break; +#define SDL_SCANCODE_LSHIFT: +#define SDL_SCANCODE_RSHIFT: keynum = K_SHIFT; break; +#define SDL_SCANCODE_LGUI: +#define SDL_SCANCODE_RGUI: keynum = K_WIN; break; +#define SDL_SCANCODE_INSERT: keynum = K_INS; break; +#define SDL_SCANCODE_DELETE: keynum = K_DEL; break; +#define SDL_SCANCODE_PAGEDOWN: keynum = K_PGDN; break; +#define SDL_SCANCODE_PAGEUP: keynum = K_PGUP; break; +#define SDL_SCANCODE_HOME: keynum = K_HOME; break; +#define SDL_SCANCODE_END: keynum = K_END; break; +#define SDL_SCANCODE_KP_1: keynum = numLock ? '1' : K_KP_END; break; +#define SDL_SCANCODE_KP_2: keynum = numLock ? '2' : K_KP_DOWNARROW; break; +#define SDL_SCANCODE_KP_3: keynum = numLock ? '3' : K_KP_PGDN; break; +#define SDL_SCANCODE_KP_4: keynum = numLock ? '4' : K_KP_LEFTARROW; break; +#define SDL_SCANCODE_KP_5: keynum = numLock ? '5' : K_KP_5; break; +#define SDL_SCANCODE_KP_6: keynum = numLock ? '6' : K_KP_RIGHTARROW; break; +#define SDL_SCANCODE_KP_7: keynum = numLock ? '7' : K_KP_HOME; break; +#define SDL_SCANCODE_KP_8: keynum = numLock ? '8' : K_KP_UPARROW; break; +#define SDL_SCANCODE_KP_9: keynum = numLock ? '9' : K_KP_PGUP; break; +#define SDL_SCANCODE_KP_0: keynum = numLock ? '0' : K_KP_INS; break; +#define SDL_SCANCODE_KP_PERIOD: keynum = K_KP_DEL; break; +#define SDL_SCANCODE_KP_ENTER: keynum = K_KP_ENTER; break; +#define SDL_SCANCODE_KP_PLUS: keynum = K_KP_PLUS; break; +#define SDL_SCANCODE_KP_MINUS: keynum = K_KP_MINUS; break; +#define SDL_SCANCODE_KP_DIVIDE: keynum = K_KP_SLASH; break; +#define SDL_SCANCODE_KP_MULTIPLY: keynum = '*'; break; +#define SDL_SCANCODE_NUMLOCKCLEAR: keynum = K_KP_NUMLOCK; break; +#define SDL_SCANCODE_CAPSLOCK: keynum = K_CAPSLOCK; break; +#define SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ??? +#define SDL_SCANCODE_SLASH: keynum = '/'; break; +#define SDL_SCANCODE_PERIOD: keynum = '.'; break; +#define SDL_SCANCODE_SEMICOLON: keynum = ';'; break; +#define SDL_SCANCODE_APOSTROPHE: keynum = '\''; break; +#define SDL_SCANCODE_COMMA: keynum = ','; break; +#define SDL_SCANCODE_PRINTSCREEN: +#endif + /* ============= SDLash_KeyEvent @@ -39,7 +103,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) int keynum = key.keysym.scancode; qboolean numLock = SDL_GetModState() & KMOD_NUM; -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( SDL_IsTextInputActive() && down ) { if( SDL_GetModState() & KMOD_CTRL ) @@ -53,7 +117,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) return; } } -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) #define DECLARE_KEY_RANGE( min, max, repl ) \ if( keynum >= (min) && keynum <= (max) ) \ @@ -61,7 +125,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) keynum = keynum - (min) + (repl); \ } -#if XASH_SDL == 2 DECLARE_KEY_RANGE( SDL_SCANCODE_A, SDL_SCANCODE_Z, 'a' ) else DECLARE_KEY_RANGE( SDL_SCANCODE_1, SDL_SCANCODE_9, '1' ) else DECLARE_KEY_RANGE( SDL_SCANCODE_F1, SDL_SCANCODE_F12, K_F1 ) @@ -129,6 +192,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; break; } +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) // don't console spam on known functional buttons, but not used in engine case SDL_SCANCODE_MUTE: case SDL_SCANCODE_VOLUMEUP: @@ -136,6 +200,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) case SDL_SCANCODE_BRIGHTNESSDOWN: case SDL_SCANCODE_BRIGHTNESSUP: return; +#endif case SDL_SCANCODE_UNKNOWN: { if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown scancode\n" ); diff --git a/engine/platform/sdl/in_sdl.c b/engine/platform/sdl/in_sdl.c index 3486c9be..d875a04d 100644 --- a/engine/platform/sdl/in_sdl.c +++ b/engine/platform/sdl/in_sdl.c @@ -25,9 +25,13 @@ GNU General Public License for more details. #include "vid_common.h" static SDL_Joystick *joy; -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) static SDL_GameController *gamecontroller; -#endif // XASH_SDL == 2 +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) + +#define SDL_WarpMouseInWindow( win, x, y ) SDL_WarpMouse( ( x ), ( y ) ) + +#endif /* ============= @@ -48,11 +52,7 @@ Platform_SetMousePos */ void Platform_SetMousePos( int x, int y ) { -#if XASH_SDL == 2 SDL_WarpMouseInWindow( host.hWnd, x, y ); -#else - SDL_WarpMouse( x, y ); -#endif } /* @@ -63,7 +63,7 @@ Platform_GetClipobardText */ void Platform_GetClipboardText( char *buffer, size_t size ) { -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) char *sdlbuffer = SDL_GetClipboardText(); if( !sdlbuffer ) @@ -71,9 +71,9 @@ void Platform_GetClipboardText( char *buffer, size_t size ) Q_strncpy( buffer, sdlbuffer, size ); SDL_free( sdlbuffer ); -#else +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) buffer[0] = 0; -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } /* @@ -84,9 +84,9 @@ Platform_SetClipobardText */ void Platform_SetClipboardText( const char *buffer, size_t size ) { -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_SetClipboardText( buffer ); -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } /* @@ -108,9 +108,9 @@ SDLash_EnableTextInput */ void Platform_EnableTextInput( qboolean enable ) { -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) enable ? SDL_StartTextInput() : SDL_StopTextInput(); -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } /* @@ -148,10 +148,10 @@ static int SDLash_JoyInit_Old( int numjoy ) return 0; } -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) for( i = 0; i < num; i++ ) Con_Reportf( "%i\t: %s\n", i, SDL_JoystickNameForIndex( i ) ); -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) Con_Reportf( "Pass +set joy_index N to command line, where N is number, to select active joystick\n" ); @@ -163,7 +163,7 @@ static int SDLash_JoyInit_Old( int numjoy ) return 0; } -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) Con_Reportf( "Selected joystick: %s\n" "\tAxes: %i\n" "\tHats: %i\n" @@ -173,13 +173,13 @@ static int SDLash_JoyInit_Old( int numjoy ) SDL_JoystickNumButtons( joy ), SDL_JoystickNumBalls( joy ) ); SDL_GameControllerEventState( SDL_DISABLE ); -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_JoystickEventState( SDL_ENABLE ); return num; } -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) /* ============= SDLash_JoyInit_New @@ -238,19 +238,19 @@ static int SDLash_JoyInit_New( int numjoy ) return 0; } // was added in SDL2-2.0.6, allow build with earlier versions just in case -#if SDL_MAJOR_VERSION > 2 || SDL_MINOR_VERSION > 0 || SDL_PATCHLEVEL >= 6 +#if SDL_VERSION_ATLEAST( 2, 0, 6 ) Con_Reportf( "Selected joystick: %s (%i:%i:%i)\n", SDL_GameControllerName( gamecontroller ), SDL_GameControllerGetVendor( gamecontroller ), SDL_GameControllerGetProduct( gamecontroller ), SDL_GameControllerGetProductVersion( gamecontroller )); -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 6 ) SDL_GameControllerEventState( SDL_ENABLE ); SDL_JoystickEventState( SDL_DISABLE ); return num; } -#endif // XASH_SDL == 2 +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) /* ============= @@ -260,12 +260,12 @@ Platform_JoyInit */ int Platform_JoyInit( int numjoy ) { -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) // SDL_Joystick is now an old API // SDL_GameController is preferred if( !Sys_CheckParm( "-sdl_joy_old_api" ) ) return SDLash_JoyInit_New(numjoy); -#endif // XASH_SDL == 2 +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) return SDLash_JoyInit_Old(numjoy); } diff --git a/engine/platform/sdl/s_sdl.c b/engine/platform/sdl/s_sdl.c index 3a3497c5..24829a90 100644 --- a/engine/platform/sdl/s_sdl.c +++ b/engine/platform/sdl/s_sdl.c @@ -24,6 +24,15 @@ GNU General Public License for more details. #define SAMPLE_16BIT_SHIFT 1 #define SECONDARY_BUFFER_SIZE 0x10000 +#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) +#include +#define SDL_setenv setenv +#define SDL_GetCurrentAudioDriver() "legacysdl" +#define SDL_OpenAudioDevice( a, b, c, d, e ) SDL_OpenAudio( ( c ), ( d ) ) +#define SDL_CloseAudioDevice( a ) SDL_CloseAudio() +#define SDL_PauseAudioDevice( a, b ) SDL_PauseAudio( ( b ) ) +#endif + /* ======================================================================= Global variables. Must be visible to window-procedure function @@ -76,10 +85,8 @@ qboolean SNDDMA_Init( void ) // even if we don't have PA // we still can safely set env variables -#if XASH_SDL == 2 SDL_setenv( "PULSE_PROP_application.name", GI->title, 1 ); SDL_setenv( "PULSE_PROP_media.role", "game", 1 ); -#endif memset( &desired, 0, sizeof( desired ) ); desired.freq = SOUND_DMA_SPEED; @@ -88,10 +95,7 @@ qboolean SNDDMA_Init( void ) desired.channels = 2; desired.callback = SDL_SoundCallback; -#if XASH_SDL == 2 sdl_dev = SDL_OpenAudioDevice( NULL, 0, &desired, &obtained, 0 ); -#endif - sdl_dev = SDL_OpenAudio( &desired, &obtained ); if( !sdl_dev ) { @@ -121,11 +125,7 @@ qboolean SNDDMA_Init( void ) dma.buffer = Z_Malloc( dma.samples * 2 ); dma.samplepos = 0; -#if XASH_SDL == 2 Con_Printf( "Using SDL audio driver: %s @ %d Hz\n", SDL_GetCurrentAudioDriver( ), obtained.freq ); -#else - Con_Printf( "Using SDL audio driver @ %d Hz\n", obtained.freq ); -#endif SNDDMA_Activate( true ); @@ -230,10 +230,7 @@ void SNDDMA_Shutdown( void ) SNDDMA_Activate( false ); #ifndef __EMSCRIPTEN__ -#if XASH_SDL == 2 SDL_CloseAudioDevice( sdl_dev ); -#endif - SDL_CloseAudio( ); #endif } @@ -259,10 +256,6 @@ between a deactivate and an activate. */ void SNDDMA_Activate( qboolean active ) { -#if XASH_SDL == 2 SDL_PauseAudioDevice( sdl_dev, !active ); -#else - SDL_PauseAudio( !active ); -#endif } #endif // XASH_SOUND == SOUND_SDL diff --git a/engine/platform/sdl/vid_sdl.c b/engine/platform/sdl/vid_sdl.c index 45205462..dc710b23 100644 --- a/engine/platform/sdl/vid_sdl.c +++ b/engine/platform/sdl/vid_sdl.c @@ -31,7 +31,7 @@ struct struct { -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST(2, 0, 0) SDL_Renderer *renderer; SDL_Texture *tex; #endif @@ -45,7 +45,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * sw.width = width; sw.height = height; -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST(2, 0, 0) if( sw.renderer ) { unsigned int format = SDL_GetWindowPixelFormat( host.hWnd ); @@ -115,11 +115,11 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * } #endif -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( !sw.renderer ) { sw.win = SDL_GetWindowSurface( host.hWnd ); -#else +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) { sw.win = SDL_GetVideoSurface(); #endif @@ -154,7 +154,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * void *SW_LockBuffer( void ) { -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( sw.renderer ) { void *pixels; @@ -169,22 +169,22 @@ void *SW_LockBuffer( void ) sw.win = SDL_GetWindowSurface( host.hWnd ); //if( !sw.win ) //SDL_GetWindowSurface( host.hWnd ); -#else +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) sw.win = SDL_GetVideoSurface(); -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) // prevent buffer overrun if( !sw.win || sw.win->w < sw.width || sw.win->h < sw.height ) return NULL; -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( sw.surf ) { SDL_LockSurface( sw.surf ); return sw.surf->pixels; } else -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) { // real window pixels (x11 shm region, dma buffer, etc) // or SDL_Renderer texture if not supported @@ -195,7 +195,7 @@ void *SW_LockBuffer( void ) void SW_UnlockBuffer( void ) { -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( sw.renderer ) { SDL_Rect src, dst; @@ -227,14 +227,14 @@ void SW_UnlockBuffer( void ) SDL_BlitSurface( sw.surf, &src, sw.win, &dst ); return; } -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) // already blitted SDL_UnlockSurface( sw.win ); -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_UpdateWindowSurface( host.hWnd ); -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } int R_MaxVideoModes( void ) @@ -254,7 +254,7 @@ vidmode_t *R_GetVideoMode( int num ) static void R_InitVideoModes( void ) { -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) int displayIndex = 0; // TODO: handle multiple displays somehow int i, modes; @@ -299,8 +299,11 @@ static void R_InitVideoModes( void ) num_vidmodes++; } -#else - int i; +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) + +# error TODO +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) + } static void R_FreeVideoModes( void ) @@ -405,6 +408,7 @@ GL_UpdateSwapInterval */ void GL_UpdateSwapInterval( void ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) // disable VSync while level is loading if( cls.state < ca_active ) { @@ -418,6 +422,7 @@ void GL_UpdateSwapInterval( void ) if( SDL_GL_SetSwapInterval( gl_vsync->value ) ) Con_Reportf( S_ERROR "SDL_GL_SetSwapInterval: %s\n", SDL_GetError( ) ); } +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } /* @@ -429,12 +434,13 @@ always return false */ qboolean GL_DeleteContext( void ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( glw_state.context ) { SDL_GL_DeleteContext(glw_state.context); glw_state.context = NULL; } - +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) return false; } @@ -445,12 +451,13 @@ GL_CreateContext */ qboolean GL_CreateContext( void ) { +#if SDL_VERSION_ATLEAST(2, 0, 0) if( ( glw_state.context = SDL_GL_CreateContext( host.hWnd ) ) == NULL) { Con_Reportf( S_ERROR "GL_CreateContext: %s\n", SDL_GetError()); return GL_DeleteContext(); } - +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) return true; } @@ -461,12 +468,13 @@ GL_UpdateContext */ qboolean GL_UpdateContext( void ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( SDL_GL_MakeCurrent( host.hWnd, glw_state.context )) { Con_Reportf( S_ERROR "GL_UpdateContext: %s\n", SDL_GetError()); return GL_DeleteContext(); } - +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) return true; } From 7f1dd248c2e8d1846972387e935a0a7248d271f0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 26 Oct 2019 04:35:56 +0300 Subject: [PATCH 06/19] backends: add XASH_MESSAGEBOX to specify messagebox platform implementation --- common/backends.h | 6 ++++++ common/defaults.h | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/common/backends.h b/common/backends.h index f3a59310..b6236fbc 100644 --- a/common/backends.h +++ b/common/backends.h @@ -47,4 +47,10 @@ GNU General Public License for more details. #define TIMER_LINUX 2 #define TIMER_WIN32 3 +// messageboxes (XASH_MESSAGEBOX) +#define MSGBOX_STDERR 0 +#define MSGBOX_SDL 1 +#define MSGBOX_ANDROID 2 +#define MSGBOX_WIN32 3 + #endif /* BACKENDS_H */ diff --git a/common/defaults.h b/common/defaults.h index 2848d879..9b7cd196 100644 --- a/common/defaults.h +++ b/common/defaults.h @@ -31,10 +31,18 @@ SETUP BACKENDS DEFINITIONS #ifndef XASH_TIMER #define XASH_TIMER TIMER_SDL #endif + + #ifndef XASH_MESSAGEBOX + #define XASH_MESSAGEBOX MSGBOX_SDL + #endif #else #ifndef XASH_TIMER #define XASH_TIMER TIMER_LINUX #endif + + #ifndef XASH_MESSAGEBOX + #define XASH_MESSAGEBOX MSGBOX_STDERR + #endif #endif #ifdef XASH_SDL @@ -70,6 +78,10 @@ SETUP BACKENDS DEFINITIONS #ifndef XASH_SOUND #define XASH_SOUND SOUND_OPENSLES #endif + + #ifndef XASH_MESSAGEBOX + #define XASH_MESSAGEBOX MSGBOX_ANDROID + #endif #endif // android case #ifdef XASH_FBDEV @@ -88,6 +100,10 @@ SETUP BACKENDS DEFINITIONS #ifndef XASH_SOUND #define XASH_SOUND SOUND_ALSA #endif + + #ifndef XASH_MESSAGEBOX + #define XASH_MESSAGEBOX MSGBOX_STDERR + #endif #define XASH_USE_EVDEV #endif // android case @@ -130,6 +146,10 @@ SETUP BACKENDS DEFINITIONS #define XASH_INPUT INPUT_NULL #endif +#ifndef XASH_MESSAGEBOX + #define XASH_MESSAGEBOX MSGBOX_STDERR +#endif + /* ========================================================================= From 9d826016b005f24b6881837fad53bb32bb47a13b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 26 Oct 2019 04:36:43 +0300 Subject: [PATCH 07/19] engine: finish sdl1.2 port --- engine/client/client.h | 1 + engine/client/input.c | 18 +- engine/client/keys.c | 20 +- engine/client/vgui/vgui_draw.c | 6 +- engine/client/vid_common.h | 1 - engine/common/host.c | 2 - engine/platform/android/android.c | 2 + engine/platform/linux/in_evdev.c | 6 +- engine/platform/linux/vid_fbdev.c | 4 - engine/platform/platform.h | 10 + engine/platform/posix/sys_posix.c | 2 +- engine/platform/sdl/events.c | 404 +++++++++++++++--------------- engine/platform/sdl/s_sdl.c | 12 +- engine/platform/sdl/sys_sdl.c | 2 + engine/platform/sdl/vid_sdl.c | 178 ++++++++++--- engine/platform/win32/sys_win.c | 4 +- 16 files changed, 409 insertions(+), 263 deletions(-) diff --git a/engine/client/client.h b/engine/client/client.h index 00b8b61c..fa5ec2a6 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -1137,6 +1137,7 @@ int Key_GetKey( const char *binding ); void Key_EnumCmds_f( void ); void Key_SetKeyDest( int key_dest ); void Key_EnableTextInput( qboolean enable, qboolean force ); +int Key_ToUpper( int key ); void OSK_Draw( void ); extern rgba_t g_color_table[8]; diff --git a/engine/client/input.c b/engine/client/input.c index 1e0c87d9..68f8b05e 100644 --- a/engine/client/input.c +++ b/engine/client/input.c @@ -194,28 +194,30 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) else if( newstate == key_game ) { // reset mouse pos, so cancel effect in game -#if XASH_SDL == 2 - if( CVAR_TO_BOOL(touch_enable) ) +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) + if( CVAR_TO_BOOL( touch_enable ) ) { SDL_SetRelativeMouseMode( SDL_FALSE ); SDL_SetWindowGrab( host.hWnd, SDL_FALSE ); } else +#endif { Platform_SetMousePos( host.window_center_x, host.window_center_y ); SDL_SetWindowGrab( host.hWnd, SDL_TRUE ); +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( clgame.dllFuncs.pfnLookEvent ) SDL_SetRelativeMouseMode( SDL_TRUE ); +#endif } -#endif // XASH_SDL if( cls.initialized ) clgame.dllFuncs.IN_ActivateMouse(); } if( ( newstate == key_menu || newstate == key_console || newstate == key_message ) && ( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( ))) { -#if XASH_SDL == 2 SDL_SetWindowGrab(host.hWnd, SDL_FALSE); +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( clgame.dllFuncs.pfnLookEvent ) SDL_SetRelativeMouseMode( SDL_FALSE ); #endif @@ -316,9 +318,7 @@ void IN_DeactivateMouse( void ) } in_mouseactive = false; -#if XASH_SDL == 2 SDL_SetWindowGrab( host.hWnd, SDL_FALSE ); -#endif } /* @@ -416,10 +416,12 @@ void IN_MouseEvent( void ) } else { -#if XASH_SDL == 2 && !defined(_WIN32) +#if XASH_SDL && !defined(_WIN32) +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_SetRelativeMouseMode( SDL_FALSE ); +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_ShowCursor( SDL_TRUE ); -#endif +#endif // XASH_SDL && !defined(_WIN32) IN_MouseMove(); } } diff --git a/engine/client/keys.c b/engine/client/keys.c index e2982dd3..0c9f7ca3 100644 --- a/engine/client/keys.c +++ b/engine/client/keys.c @@ -815,8 +815,7 @@ void Key_EnableTextInput( qboolean enable, qboolean force ) else if( !enable ) Platform_EnableTextInput( false ); - if( !force ) - host.textmode = enable; + host.textmode = enable; } /* @@ -907,6 +906,23 @@ void CL_CharEvent( int key ) } } +/* +============ +Key_ToUpper + +A helper function if platform input doesn't support text mode properly +============ +*/ +int Key_ToUpper( int keynum ) +{ + keynum = Q_toupper( keynum ); + if( keynum == '-' ) + keynum = '_'; + if( keynum == '=' ) + keynum = '+'; + + return keynum; +} /* On-screen keyboard: * diff --git a/engine/client/vgui/vgui_draw.c b/engine/client/vgui/vgui_draw.c index 79cc0bab..d87cf5d1 100644 --- a/engine/client/vgui/vgui_draw.c +++ b/engine/client/vgui/vgui_draw.c @@ -25,7 +25,7 @@ GNU General Public License for more details. #include "ref_common.h" #include "input.h" #ifdef XASH_SDL -#include +#include static SDL_Cursor* s_pDefaultCursor[20]; #endif #include "platform/platform.h" @@ -72,7 +72,7 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y ) void VGUI_InitCursors( void ) { // load up all default cursors -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) s_pDefaultCursor[dc_none] = NULL; s_pDefaultCursor[dc_arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); s_pDefaultCursor[dc_ibeam] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); @@ -108,7 +108,7 @@ void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor ) break; } -#if XASH_SDL == 2 +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) /// TODO: platform cursors if( CVAR_TO_BOOL( touch_emulate ) ) diff --git a/engine/client/vid_common.h b/engine/client/vid_common.h index f95d2531..7adef525 100644 --- a/engine/client/vid_common.h +++ b/engine/client/vid_common.h @@ -16,7 +16,6 @@ typedef struct int safe; int desktopBitsPixel; - int desktopWidth; int desktopHeight; qboolean initialized; // OpenGL subsystem started diff --git a/engine/common/host.c b/engine/common/host.c index b7449670..d530e110 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -323,9 +323,7 @@ void Host_MemStats_f( void ) void Host_Minimize_f( void ) { -#if XASH_SDL == 2 if( host.hWnd ) SDL_MinimizeWindow( host.hWnd ); -#endif } /* diff --git a/engine/platform/android/android.c b/engine/platform/android/android.c index 583bb4c6..b87a259d 100644 --- a/engine/platform/android/android.c +++ b/engine/platform/android/android.c @@ -645,10 +645,12 @@ Android_MessageBox Show messagebox and wait for OK button press ======================== */ +#if XASH_MESSAGEBOX == MSGBOX_ANDROID void Platform_MessageBox( const char *title, const char *text, qboolean parentMainWindow ) { (*jni.env)->CallStaticVoidMethod( jni.env, jni.actcls, jni.messageBox, (*jni.env)->NewStringUTF( jni.env, title ), (*jni.env)->NewStringUTF( jni.env ,text ) ); } +#endif // XASH_MESSAGEBOX == MSGBOX_ANDROID /* ======================== diff --git a/engine/platform/linux/in_evdev.c b/engine/platform/linux/in_evdev.c index 3405a60e..90e24f8a 100644 --- a/engine/platform/linux/in_evdev.c +++ b/engine/platform/linux/in_evdev.c @@ -378,11 +378,7 @@ void IN_EvdevFrame ( void ) { if( evdev.shift ) { - key = Q_toupper( key ); - if( key == '-' ) - key = '_'; - if( key == '=' ) - key = '+'; + key = Key_ToUpper( key ); } CL_CharEvent( key ); } diff --git a/engine/platform/linux/vid_fbdev.c b/engine/platform/linux/vid_fbdev.c index f9915db7..4e2d7cda 100644 --- a/engine/platform/linux/vid_fbdev.c +++ b/engine/platform/linux/vid_fbdev.c @@ -266,10 +266,6 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * } // unrelated stubs -void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow ) -{ - -} void Platform_GetClipboardText( char *buffer, size_t size ) { diff --git a/engine/platform/platform.h b/engine/platform/platform.h index 93d73afb..21772b80 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -73,6 +73,16 @@ void Platform_PreCreateMove( void ); void Platform_GetClipboardText( char *buffer, size_t size ); void Platform_SetClipboardText( const char *buffer, size_t size ); +#if XASH_SDL == 12 +#define SDL_SetWindowGrab( wnd, state ) SDL_WM_GrabInput( (state) ) +#define SDL_MinimizeWindow( wnd ) SDL_WM_IconifyWindow() +#define SDL_IsTextInputActive() host.textmode +#endif + +#if !XASH_SDL +#define SDL_VERSION_ATLEAST( x, y, z ) 0 +#endif + #ifdef __ANDROID__ void Android_ShowMouse( qboolean show ); void Android_MouseMove( float *x, float *y ); diff --git a/engine/platform/posix/sys_posix.c b/engine/platform/posix/sys_posix.c index 3b40fa00..c5a4cbff 100644 --- a/engine/platform/posix/sys_posix.c +++ b/engine/platform/posix/sys_posix.c @@ -92,7 +92,7 @@ void Platform_ShellExecute( const char *path, const char *parms ) } #endif // __ANDROID__ -#ifdef XASH_DEDICATED +#if XASH_MESSAGEBOX == MSGBOX_STDERR void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow ) { fprintf( stderr, diff --git a/engine/platform/sdl/events.c b/engine/platform/sdl/events.c index e888b86f..1824b34f 100644 --- a/engine/platform/sdl/events.c +++ b/engine/platform/sdl/events.c @@ -15,6 +15,7 @@ GNU General Public License for more details. #if defined( XASH_SDL ) && !defined( XASH_DEDICATED ) #include +#include #include "common.h" #include "keydefs.h" @@ -39,56 +40,57 @@ static int wheelbutton; #define SDL_SCANCODE_BACKSLASH SDLK_BACKSLASH #define SDL_SCANCODE_LEFTBRACKET SDLK_LEFTBRACKET #define SDL_SCANCODE_RIGHTBRACKET SDLK_RIGHTBRACKET -#define SDL_SCANCODE_EQUALS: keynum = '='; break; -#define SDL_SCANCODE_MINUS: keynum = '-'; break; -#define SDL_SCANCODE_TAB: keynum = K_TAB; break; -#define SDL_SCANCODE_RETURN: keynum = K_ENTER; break; -#define SDL_SCANCODE_ESCAPE: keynum = K_ESCAPE; break; -#define SDL_SCANCODE_SPACE: keynum = K_SPACE; break; -#define SDL_SCANCODE_BACKSPACE: keynum = K_BACKSPACE; break; -#define SDL_SCANCODE_UP: keynum = K_UPARROW; break; -#define SDL_SCANCODE_LEFT: keynum = K_LEFTARROW; break; -#define SDL_SCANCODE_DOWN: keynum = K_DOWNARROW; break; -#define SDL_SCANCODE_RIGHT: keynum = K_RIGHTARROW; break; -#define SDL_SCANCODE_LALT: -#define SDL_SCANCODE_RALT: keynum = K_ALT; break; -#define SDL_SCANCODE_LCTRL: -#define SDL_SCANCODE_RCTRL: keynum = K_CTRL; break; -#define SDL_SCANCODE_LSHIFT: -#define SDL_SCANCODE_RSHIFT: keynum = K_SHIFT; break; -#define SDL_SCANCODE_LGUI: -#define SDL_SCANCODE_RGUI: keynum = K_WIN; break; -#define SDL_SCANCODE_INSERT: keynum = K_INS; break; -#define SDL_SCANCODE_DELETE: keynum = K_DEL; break; -#define SDL_SCANCODE_PAGEDOWN: keynum = K_PGDN; break; -#define SDL_SCANCODE_PAGEUP: keynum = K_PGUP; break; -#define SDL_SCANCODE_HOME: keynum = K_HOME; break; -#define SDL_SCANCODE_END: keynum = K_END; break; -#define SDL_SCANCODE_KP_1: keynum = numLock ? '1' : K_KP_END; break; -#define SDL_SCANCODE_KP_2: keynum = numLock ? '2' : K_KP_DOWNARROW; break; -#define SDL_SCANCODE_KP_3: keynum = numLock ? '3' : K_KP_PGDN; break; -#define SDL_SCANCODE_KP_4: keynum = numLock ? '4' : K_KP_LEFTARROW; break; -#define SDL_SCANCODE_KP_5: keynum = numLock ? '5' : K_KP_5; break; -#define SDL_SCANCODE_KP_6: keynum = numLock ? '6' : K_KP_RIGHTARROW; break; -#define SDL_SCANCODE_KP_7: keynum = numLock ? '7' : K_KP_HOME; break; -#define SDL_SCANCODE_KP_8: keynum = numLock ? '8' : K_KP_UPARROW; break; -#define SDL_SCANCODE_KP_9: keynum = numLock ? '9' : K_KP_PGUP; break; -#define SDL_SCANCODE_KP_0: keynum = numLock ? '0' : K_KP_INS; break; -#define SDL_SCANCODE_KP_PERIOD: keynum = K_KP_DEL; break; -#define SDL_SCANCODE_KP_ENTER: keynum = K_KP_ENTER; break; -#define SDL_SCANCODE_KP_PLUS: keynum = K_KP_PLUS; break; -#define SDL_SCANCODE_KP_MINUS: keynum = K_KP_MINUS; break; -#define SDL_SCANCODE_KP_DIVIDE: keynum = K_KP_SLASH; break; -#define SDL_SCANCODE_KP_MULTIPLY: keynum = '*'; break; -#define SDL_SCANCODE_NUMLOCKCLEAR: keynum = K_KP_NUMLOCK; break; -#define SDL_SCANCODE_CAPSLOCK: keynum = K_CAPSLOCK; break; -#define SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ??? -#define SDL_SCANCODE_SLASH: keynum = '/'; break; -#define SDL_SCANCODE_PERIOD: keynum = '.'; break; -#define SDL_SCANCODE_SEMICOLON: keynum = ';'; break; -#define SDL_SCANCODE_APOSTROPHE: keynum = '\''; break; -#define SDL_SCANCODE_COMMA: keynum = ','; break; -#define SDL_SCANCODE_PRINTSCREEN: +#define SDL_SCANCODE_EQUALS SDLK_EQUALS +#define SDL_SCANCODE_MINUS SDLK_MINUS +#define SDL_SCANCODE_TAB SDLK_TAB +#define SDL_SCANCODE_RETURN SDLK_RETURN +#define SDL_SCANCODE_ESCAPE SDLK_ESCAPE +#define SDL_SCANCODE_SPACE SDLK_SPACE +#define SDL_SCANCODE_BACKSPACE SDLK_BACKSPACE +#define SDL_SCANCODE_UP SDLK_UP +#define SDL_SCANCODE_LEFT SDLK_LEFT +#define SDL_SCANCODE_DOWN SDLK_DOWN +#define SDL_SCANCODE_RIGHT SDLK_RIGHT +#define SDL_SCANCODE_LALT SDLK_LALT +#define SDL_SCANCODE_RALT SDLK_RALT +#define SDL_SCANCODE_LCTRL SDLK_LCTRL +#define SDL_SCANCODE_RCTRL SDLK_RCTRL +#define SDL_SCANCODE_LSHIFT SDLK_LSHIFT +#define SDL_SCANCODE_RSHIFT SDLK_RSHIFT +#define SDL_SCANCODE_LGUI SDLK_LMETA +#define SDL_SCANCODE_RGUI SDLK_RMETA +#define SDL_SCANCODE_INSERT SDLK_INSERT +#define SDL_SCANCODE_DELETE SDLK_DELETE +#define SDL_SCANCODE_PAGEDOWN SDLK_PAGEDOWN +#define SDL_SCANCODE_PAGEUP SDLK_PAGEUP +#define SDL_SCANCODE_HOME SDLK_HOME +#define SDL_SCANCODE_END SDLK_END +#define SDL_SCANCODE_KP_1 SDLK_KP1 +#define SDL_SCANCODE_KP_2 SDLK_KP2 +#define SDL_SCANCODE_KP_3 SDLK_KP3 +#define SDL_SCANCODE_KP_4 SDLK_KP4 +#define SDL_SCANCODE_KP_5 SDLK_KP5 +#define SDL_SCANCODE_KP_6 SDLK_KP6 +#define SDL_SCANCODE_KP_7 SDLK_KP7 +#define SDL_SCANCODE_KP_8 SDLK_KP8 +#define SDL_SCANCODE_KP_9 SDLK_KP9 +#define SDL_SCANCODE_KP_0 SDLK_KP0 +#define SDL_SCANCODE_KP_PERIOD SDLK_KP_PERIOD +#define SDL_SCANCODE_KP_ENTER SDLK_KP_ENTER +#define SDL_SCANCODE_KP_PLUS SDLK_KP_PLUS +#define SDL_SCANCODE_KP_MINUS SDLK_KP_MINUS +#define SDL_SCANCODE_KP_DIVIDE SDLK_KP_DIVIDE +#define SDL_SCANCODE_KP_MULTIPLY SDLK_KP_MULTIPLY +#define SDL_SCANCODE_NUMLOCKCLEAR SDLK_NUMLOCK +#define SDL_SCANCODE_CAPSLOCK SDLK_CAPSLOCK +#define SDL_SCANCODE_SLASH SDLK_SLASH +#define SDL_SCANCODE_PERIOD SDLK_PERIOD +#define SDL_SCANCODE_SEMICOLON SDLK_SEMICOLON +#define SDL_SCANCODE_APOSTROPHE SDLK_QUOTE +#define SDL_SCANCODE_COMMA SDLK_COMMA +#define SDL_SCANCODE_PRINTSCREEN SDLK_PRINT +#define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN +#define SDL_GetScancodeName( x ) "unknown" #endif /* @@ -100,10 +102,13 @@ SDLash_KeyEvent static void SDLash_KeyEvent( SDL_KeyboardEvent key ) { int down = key.state != SDL_RELEASED; +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) int keynum = key.keysym.scancode; +#else + int keynum = key.keysym.sym; +#endif qboolean numLock = SDL_GetModState() & KMOD_NUM; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( SDL_IsTextInputActive() && down ) { if( SDL_GetModState() & KMOD_CTRL ) @@ -116,8 +121,23 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) return; } + +#if !SDL_VERSION_ATLEAST( 2, 0, 0 ) + if( keynum >= SDLK_KP0 && keynum <= SDLK_KP9 ) + keynum -= SDLK_KP0 + '0'; + + if( isprint( keynum ) ) + { + if( SDL_GetModState() & KMOD_SHIFT ) + { + keynum = Key_ToUpper( keynum ); + } + + CL_CharEvent( keynum ); + return; + } +#endif } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) #define DECLARE_KEY_RANGE( min, max, repl ) \ if( keynum >= (min) && keynum <= (max) ) \ @@ -180,7 +200,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) case SDL_SCANCODE_KP_MULTIPLY: keynum = '*'; break; case SDL_SCANCODE_NUMLOCKCLEAR: keynum = K_KP_NUMLOCK; break; case SDL_SCANCODE_CAPSLOCK: keynum = K_CAPSLOCK; break; - case SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ??? case SDL_SCANCODE_SLASH: keynum = '/'; break; case SDL_SCANCODE_PERIOD: keynum = '.'; break; case SDL_SCANCODE_SEMICOLON: keynum = ';'; break; @@ -193,6 +212,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) break; } #if SDL_VERSION_ATLEAST( 2, 0, 0 ) + case SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ??? // don't console spam on known functional buttons, but not used in engine case SDL_SCANCODE_MUTE: case SDL_SCANCODE_VOLUMEUP: @@ -200,7 +220,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) case SDL_SCANCODE_BRIGHTNESSDOWN: case SDL_SCANCODE_BRIGHTNESSUP: return; -#endif +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) case SDL_SCANCODE_UNKNOWN: { if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown scancode\n" ); @@ -211,90 +231,24 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) return; } } -#else - DECLARE_KEY_RANGE( SDLK_a, SDLK_z, 'a' ) - else DECLARE_KEY_RANGE( SDLK_1, SDLK_9, '1' ) - else DECLARE_KEY_RANGE( SDLK_F1, SDLK_F12, K_F1 ) - else - { - switch( keynum ) - { - case SDLK_BACKQUOTE: keynum = '`'; break; - case SDLK_0: keynum = '0'; break; - case SDLK_BACKSLASH: keynum = '\\'; break; - case SDLK_LEFTBRACKET: keynum = '['; break; - case SDLK_RIGHTBRACKET: keynum = ']'; break; - case SDLK_EQUALS: keynum = '='; break; - case SDLK_MINUS: keynum = '-'; break; - case SDLK_TAB: keynum = K_TAB; break; - case SDLK_RETURN: keynum = K_ENTER; break; - case SDLK_ESCAPE: keynum = K_ESCAPE; break; - case SDLK_SPACE: keynum = K_SPACE; break; - case SDLK_BACKSPACE: keynum = K_BACKSPACE; break; - case SDLK_UP: keynum = K_UPARROW; break; - case SDLK_LEFT: keynum = K_LEFTARROW; break; - case SDLK_DOWN: keynum = K_DOWNARROW; break; - case SDLK_RIGHT: keynum = K_RIGHTARROW; break; - case SDLK_LALT: - case SDLK_RALT: keynum = K_ALT; break; - case SDLK_LCTRL: - case SDLK_RCTRL: keynum = K_CTRL; break; - case SDLK_LSHIFT: - case SDLK_RSHIFT: keynum = K_SHIFT; break; - case SDLK_LMETA: - case SDLK_RMETA: keynum = K_WIN; break; - case SDLK_INSERT: keynum = K_INS; break; - case SDLK_DELETE: keynum = K_DEL; break; - case SDLK_PAGEDOWN: keynum = K_PGDN; break; - case SDLK_PAGEUP: keynum = K_PGUP; break; - case SDLK_HOME: keynum = K_HOME; break; - case SDLK_END: keynum = K_END; break; - case SDLK_KP1: keynum = numLock ? '1' : K_KP_END; break; - case SDLK_KP2: keynum = numLock ? '2' : K_KP_DOWNARROW; break; - case SDLK_KP3: keynum = numLock ? '3' : K_KP_PGDN; break; - case SDLK_KP4: keynum = numLock ? '4' : K_KP_LEFTARROW; break; - case SDLK_KP5: keynum = numLock ? '5' : K_KP_5; break; - case SDLK_KP6: keynum = numLock ? '6' : K_KP_RIGHTARROW; break; - case SDLK_KP7: keynum = numLock ? '7' : K_KP_HOME; break; - case SDLK_KP8: keynum = numLock ? '8' : K_KP_UPARROW; break; - case SDLK_KP9: keynum = numLock ? '9' : K_KP_PGUP; break; - case SDLK_KP0: keynum = numLock ? '0' : K_KP_INS; break; - case SDLK_KP_PERIOD: keynum = K_KP_DEL; break; - case SDLK_KP_ENTER: keynum = K_KP_ENTER; break; - case SDLK_KP_PLUS: keynum = K_KP_PLUS; break; - case SDLK_KP_MINUS: keynum = K_KP_MINUS; break; - case SDLK_KP_DIVIDE: keynum = K_KP_SLASH; break; - case SDLK_KP_MULTIPLY: keynum = '*'; break; - case SDLK_NUMLOCK: keynum = K_KP_NUMLOCK; break; - case SDLK_CAPSLOCK: keynum = K_CAPSLOCK; break; - case SDLK_SLASH: keynum = '/'; break; - case SDLK_PERIOD: keynum = '.'; break; - case SDLK_SEMICOLON: keynum = ';'; break; - case SDLK_QUOTE: keynum = '\''; break; - case SDLK_COMMA: keynum = ','; break; - case SDLK_PRINT: - { - host.force_draw_version = true; - host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; - break; - } - case SDLK_UNKNOWN: - { - if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown scancode\n" ); - return; - } - default: - if( down ) Con_Reportf( "SDLash_KeyEvent: Unknown key: %s = %i\n", SDL_GetScancodeName( keynum ), keynum ); - return; - } - } -#endif #undef DECLARE_KEY_RANGE Key_Event( keynum, down ); } +static void SDLash_MouseKey( int key, int down, int istouch ) +{ + if( CVAR_TO_BOOL( touch_emulate ) ) + { + Touch_KeyEvent( key, down ); + } + else if( in_mouseinitialized && !m_ignore->value && !istouch ) + { + Key_Event( key, down ); + } +} + /* ============= SDLash_MouseEvent @@ -304,14 +258,41 @@ SDLash_MouseEvent static void SDLash_MouseEvent( SDL_MouseButtonEvent button ) { int down = button.state != SDL_RELEASED; + qboolean istouch; - if( CVAR_TO_BOOL( touch_emulate ) ) +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) + istouch = button.which == SDL_TOUCH_MOUSEID; +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) + istouch = false; +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) + + switch( button.button ) { - Touch_KeyEvent( K_MOUSE1 - 1 + button.button, down ); - } - else if( in_mouseinitialized && !m_ignore->value && button.which != SDL_TOUCH_MOUSEID ) - { - Key_Event( K_MOUSE1 - 1 + button.button, down ); + case SDL_BUTTON_LEFT: + SDLash_MouseKey( K_MOUSE1, down, istouch ); + break; + case SDL_BUTTON_RIGHT: + SDLash_MouseKey( K_MOUSE2, down, istouch ); + break; + case SDL_BUTTON_MIDDLE: + SDLash_MouseKey( K_MOUSE3, down, istouch ); + break; + case SDL_BUTTON_X1: + SDLash_MouseKey( K_MOUSE4, down, istouch ); + break; + case SDL_BUTTON_X2: + SDLash_MouseKey( K_MOUSE5, down, istouch ); + break; +#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) + case SDL_BUTTON_WHEELUP: + Key_Event( K_MWHEELUP, down ); + break; + case SDL_BUTTON_WHEELDOWN: + Key_Event( K_MWHEELDOWN, down ); + break; +#endif // ! SDL_VERSION_ATLEAST( 2, 0, 0 ) + default: + Con_Printf( "Unknown mouse button ID: %d\n", button.button ); } } @@ -321,6 +302,7 @@ SDLash_InputEvent ============= */ +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) static void SDLash_InputEvent( SDL_TextInputEvent input ) { char *text; @@ -339,6 +321,43 @@ static void SDLash_InputEvent( SDL_TextInputEvent input ) CL_CharEvent( ch ); } } +#endif // SDL_VERSION_AT_LEAST( 2, 0, 0 ) + +static void SDLash_ActiveEvent( int gain ) +{ + if( gain ) + { + host.status = HOST_FRAME; + IN_ActivateMouse(true); + if( snd_mute_losefocus->value ) + { + SNDDMA_Activate( true ); + } + host.force_draw_version = true; + host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; + if( vid_fullscreen->value ) + VID_SetMode(); + } + else + { +#if TARGET_OS_IPHONE + { + // Keep running if ftp server enabled + void IOS_StartBackgroundTask( void ); + IOS_StartBackgroundTask(); + } +#endif + host.status = HOST_NOFOCUS; + IN_DeactivateMouse(); + if( snd_mute_losefocus->value ) + { + SNDDMA_Activate( false ); + } + host.force_draw_version = true; + host.force_draw_version_time = host.realtime + 2; + VID_RestoreScreenResolution(); + } +} /* ============= @@ -360,27 +379,53 @@ static void SDLash_EventFilter( SDL_Event *event ) { /* Mouse events */ case SDL_MOUSEMOTION: - if( !host.mouse_visible && event->motion.which != SDL_TOUCH_MOUSEID ) + if( !host.mouse_visible +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) + && event->motion.which != SDL_TOUCH_MOUSEID ) +#else + ) +#endif IN_MouseEvent(); break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: - SDLash_MouseEvent( event->button ); break; - case SDL_MOUSEWHEEL: - wheelbutton = event->wheel.y < 0 ? K_MWHEELDOWN : K_MWHEELUP; - Key_Event( wheelbutton, true ); - break; - /* Keyboard events */ case SDL_KEYDOWN: case SDL_KEYUP: SDLash_KeyEvent( event->key ); break; + /* Joystick events */ + case SDL_JOYAXISMOTION: + Joy_AxisMotionEvent( event->jaxis.axis, event->jaxis.value ); + break; + + case SDL_JOYBALLMOTION: + Joy_BallMotionEvent( event->jball.ball, event->jball.xrel, event->jball.yrel ); + break; + + case SDL_JOYHATMOTION: + Joy_HatMotionEvent( event->jhat.hat, event->jhat.value ); + break; + + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + Joy_ButtonEvent( event->jbutton.button, event->jbutton.state ); + break; + + case SDL_QUIT: + Sys_Quit(); + break; +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) + case SDL_MOUSEWHEEL: + wheelbutton = event->wheel.y < 0 ? K_MWHEELDOWN : K_MWHEELUP; + Key_Event( wheelbutton, true ); + break; + /* Touch events */ case SDL_FINGERDOWN: case SDL_FINGERUP: @@ -394,7 +439,7 @@ static void SDLash_EventFilter( SDL_Event *event ) type = event_down; else if( event->type == SDL_FINGERUP ) type = event_up ; - else if(event->type == SDL_FINGERMOTION ) + else if( event->type == SDL_FINGERMOTION ) type = event_motion; else break; @@ -435,30 +480,11 @@ static void SDLash_EventFilter( SDL_Event *event ) break; } - /* IME */ case SDL_TEXTINPUT: SDLash_InputEvent( event->text ); break; - /* Joystick events */ - case SDL_JOYAXISMOTION: - Joy_AxisMotionEvent( event->jaxis.axis, event->jaxis.value ); - break; - - case SDL_JOYBALLMOTION: - Joy_BallMotionEvent( event->jball.ball, event->jball.xrel, event->jball.yrel ); - break; - - case SDL_JOYHATMOTION: - Joy_HatMotionEvent( event->jhat.hat, event->jhat.value ); - break; - - case SDL_JOYBUTTONDOWN: - case SDL_JOYBUTTONUP: - Joy_ButtonEvent( event->jbutton.button, event->jbutton.state ); - break; - case SDL_JOYDEVICEADDED: Joy_AddEvent(); break; @@ -508,10 +534,6 @@ static void SDLash_EventFilter( SDL_Event *event ) Joy_RemoveEvent( ); break; - case SDL_QUIT: - Sys_Quit(); - break; - case SDL_WINDOWEVENT: if( event->window.windowID != SDL_GetWindowID( host.hWnd ) ) return; @@ -540,47 +562,35 @@ static void SDLash_EventFilter( SDL_Event *event ) VID_SetMode(); break; case SDL_WINDOWEVENT_FOCUS_GAINED: - host.status = HOST_FRAME; - IN_ActivateMouse(true); - if( snd_mute_losefocus->value ) - { - SNDDMA_Activate( true ); - } - host.force_draw_version = true; - host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME; - if( vid_fullscreen->value ) - VID_SetMode(); + SDLash_ActiveEvent( true ); break; case SDL_WINDOWEVENT_FOCUS_LOST: -#if TARGET_OS_IPHONE - { - // Keep running if ftp server enabled - void IOS_StartBackgroundTask( void ); - IOS_StartBackgroundTask(); - } -#endif - host.status = HOST_NOFOCUS; - IN_DeactivateMouse(); - if( snd_mute_losefocus->value ) - { - SNDDMA_Activate( false ); - } - host.force_draw_version = true; - host.force_draw_version_time = host.realtime + 2; - VID_RestoreScreenResolution(); + SDLash_ActiveEvent( false ); break; case SDL_WINDOWEVENT_RESIZED: + case SDL_WINDOWEVENT_MAXIMIZED: { + int w = VID_MIN_WIDTH, h = VID_MIN_HEIGHT; if( vid_fullscreen->value ) break; - VID_SaveWindowSize( event->window.data1, event->window.data2 ); - SCR_VidInit(); // tell the client.dll what vid_mode has changed + SDL_GL_GetDrawableSize( host.hWnd, &w, &h ); + R_SaveVideoMode( w, h ); + SCR_VidInit(); // tell the client.dll that vid_mode has changed break; } default: break; } +#else + case SDL_VIDEORESIZE: + R_SaveVideoMode( event->resize.w, event->resize.h ); + SCR_VidInit(); + break; // tell the client.dll that vid_mode has changed + case SDL_ACTIVEEVENT: + SDLash_ActiveEvent( event->active.gain ); + break; +#endif } } diff --git a/engine/platform/sdl/s_sdl.c b/engine/platform/sdl/s_sdl.c index 24829a90..9948a3e7 100644 --- a/engine/platform/sdl/s_sdl.c +++ b/engine/platform/sdl/s_sdl.c @@ -31,6 +31,9 @@ GNU General Public License for more details. #define SDL_OpenAudioDevice( a, b, c, d, e ) SDL_OpenAudio( ( c ), ( d ) ) #define SDL_CloseAudioDevice( a ) SDL_CloseAudio() #define SDL_PauseAudioDevice( a, b ) SDL_PauseAudio( ( b ) ) +#define SDLash_IsAudioError( x ) ( x ) != 0 +#else +#define SDLash_IsAudioError( x ) ( x ) == 0 #endif /* @@ -50,6 +53,11 @@ void SDL_SoundCallback( void *userdata, Uint8 *stream, int len ) int pos = dma.samplepos << 1; int wrapped = pos + len - size; +#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) + if( !dma.buffer ) + return; +#endif + if( wrapped < 0 ) { memcpy( stream, dma.buffer + pos, len ); @@ -97,7 +105,7 @@ qboolean SNDDMA_Init( void ) sdl_dev = SDL_OpenAudioDevice( NULL, 0, &desired, &obtained, 0 ); - if( !sdl_dev ) + if( SDLash_IsAudioError( sdl_dev )) { Con_Printf( "Couldn't open SDL audio: %s\n", SDL_GetError( ) ); return false; @@ -122,7 +130,7 @@ qboolean SNDDMA_Init( void ) if( !samplecount ) samplecount = 0x8000; dma.samples = samplecount * obtained.channels; - dma.buffer = Z_Malloc( dma.samples * 2 ); + dma.buffer = Z_Calloc( dma.samples * 2 ); dma.samplepos = 0; Con_Printf( "Using SDL audio driver: %s @ %d Hz\n", SDL_GetCurrentAudioDriver( ), obtained.freq ); diff --git a/engine/platform/sdl/sys_sdl.c b/engine/platform/sdl/sys_sdl.c index 8a2e6391..285cfc1b 100644 --- a/engine/platform/sdl/sys_sdl.c +++ b/engine/platform/sdl/sys_sdl.c @@ -38,7 +38,9 @@ void Platform_Sleep( int msec ) } #endif // XASH_TIMER == TIMER_SDL +#if XASH_MESSAGEBOX == MSGBOX_SDL void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow ) { SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, title, message, parentMainWindow ? host.hWnd : NULL ); } +#endif // XASH_MESSAGEBOX == MSGBOX_SDL diff --git a/engine/platform/sdl/vid_sdl.c b/engine/platform/sdl/vid_sdl.c index dc710b23..ae727f75 100644 --- a/engine/platform/sdl/vid_sdl.c +++ b/engine/platform/sdl/vid_sdl.c @@ -57,7 +57,7 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * // guess if( format == SDL_PIXELFORMAT_UNKNOWN ) { - if( glw_state.desktopBitsPixel == 16 ) + if( refState.desktopBitsPixel == 16 ) format = SDL_PIXELFORMAT_RGB565; else format = SDL_PIXELFORMAT_RGBA8888; @@ -234,7 +234,9 @@ void SW_UnlockBuffer( void ) #if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_UpdateWindowSurface( host.hWnd ); -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) + SDL_Flip( host.hWnd ); +#endif } int R_MaxVideoModes( void ) @@ -269,7 +271,6 @@ static void R_InitVideoModes( void ) for( i = 0; i < modes; i++ ) { int j; - qboolean skip = false; SDL_DisplayMode mode; if( SDL_GetDisplayMode( displayIndex, i, &mode ) ) @@ -286,7 +287,6 @@ static void R_InitVideoModes( void ) if( mode.w == vidmodes[j].width && mode.h == vidmodes[j].height ) { - skip = true; break; } } @@ -300,8 +300,38 @@ static void R_InitVideoModes( void ) num_vidmodes++; } #else // SDL_VERSION_ATLEAST( 2, 0, 0 ) + SDL_Rect **modes = SDL_ListModes( NULL, SDL_FULLSCREEN ); + int len = 0, i = 0, j; -# error TODO + if( !modes || modes == (void*)-1 ) + return; + + for( len = 0; modes[len]; len++ ); + + vidmodes = Mem_Malloc( host.mempool, len * sizeof( vidmode_t ) ); + + // from smallest to largest + for( ; i < len; i++ ) + { + SDL_Rect *mode = modes[len - i - 1]; + + for( j = 0; j < num_vidmodes; j++ ) + { + if( mode->w == vidmodes[j].width && + mode->h == vidmodes[j].height ) + { + break; + } + } + if( j != num_vidmodes ) + continue; + + vidmodes[num_vidmodes].width = mode->w; + vidmodes[num_vidmodes].height = mode->h; + vidmodes[num_vidmodes].desc = copystring( va( "%ix%i", mode->w, mode->h )); + + num_vidmodes++; + } #endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } @@ -388,9 +418,9 @@ GL_GetProcAddress void *GL_GetProcAddress( const char *name ) { #if defined( XASH_NANOGL ) - void *func = nanoGL_GetProcAddress(name); + void *func = nanoGL_GetProcAddress( name ); #else - void *func = SDL_GL_GetProcAddress(name); + void *func = SDL_GL_GetProcAddress( name ); #endif if( !func ) @@ -511,6 +541,7 @@ void VID_SaveWindowSize( int width, int height ) static qboolean VID_SetScreenResolution( int width, int height ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_DisplayMode want, got; Uint32 wndFlags = 0; static string wndname; @@ -539,13 +570,16 @@ static qboolean VID_SetScreenResolution( int width, int height ) SDL_SetWindowGrab( host.hWnd, SDL_TRUE ); SDL_SetWindowSize( host.hWnd, got.w, got.h ); - VID_SaveWindowSize( got.w, got.h ); - + VID_SaveWindowSize( gow.w, got.h ); +#else + VID_SaveWindowSize( width, height ); +#endif return true; } void VID_RestoreScreenResolution( void ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( !Cvar_VariableInteger("fullscreen") ) { SDL_SetWindowBordered( host.hWnd, SDL_TRUE ); @@ -556,6 +590,7 @@ void VID_RestoreScreenResolution( void ) SDL_MinimizeWindow( host.hWnd ); SDL_SetWindowFullscreen( host.hWnd, 0 ); } +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } #if defined(_WIN32) && !defined(XASH_64BIT) // ICO support only for Win32 @@ -582,6 +617,7 @@ VID_CreateWindow qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) { static string wndname; +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) Uint32 wndFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_MOUSE_FOCUS; rgbdata_t *icon = NULL; qboolean iconLoaded = false; @@ -733,7 +769,53 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) } - VID_SaveWindowSize( width, height ); +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) + Uint32 flags = 0; + + if( fullscreen ) + { + // flags |= SDL_FULLSCREEN; + } + + if( glw_state.software ) + { + // flags |= SDL_ASYNCBLIT; + } + else + { + flags |= SDL_OPENGL; + } + + while( glw_state.safe >= SAFE_NO && glw_state.safe < SAFE_LAST ) + { + host.hWnd = sw.surf = SDL_SetVideoMode( width, height, 0, flags ); + + // we have window, exit loop + if( host.hWnd ) + break; + + Con_Reportf( S_ERROR "VID_CreateWindow: couldn't create '%s' with safegl level %d: %s\n", wndname, glw_state.safe, SDL_GetError()); + + glw_state.safe++; + + if( !gl_wgl_msaa_samples->value && glw_state.safe == SAFE_NOMSAA ) + glw_state.safe++; // no need to skip msaa, if we already disabled it + + GL_SetupAttributes(); // re-choose attributes + + // try again create window + } + + // window creation has failed... + if( glw_state.safe >= SAFE_LAST ) + { + return false; + } + + +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) + + VID_SaveVideoMode( width, height ); return true; } @@ -750,7 +832,9 @@ void VID_DestroyWindow( void ) VID_RestoreScreenResolution(); if( host.hWnd ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_DestroyWindow ( host.hWnd ); +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) host.hWnd = NULL; } @@ -767,14 +851,20 @@ GL_SetupAttributes */ static void GL_SetupAttributes( void ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_GL_ResetAttributes(); +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) ref.dllFuncs.GL_SetupAttributes( glw_state.safe ); } void GL_SwapBuffers( void ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_GL_SwapWindow( host.hWnd ); +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) + SDL_Flip( host.hWnd ); +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } int GL_SetAttribute( int attr, int val ) @@ -792,12 +882,20 @@ int GL_SetAttribute( int attr, int val ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLEBUFFERS ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLESAMPLES ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ACCELERATED_VISUAL ); +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MAJOR_VERSION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MINOR_VERSION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_EGL ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_FLAGS ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE ); + case REF_GL_CONTEXT_PROFILE_MASK: +#ifdef SDL_HINT_OPENGL_ES_DRIVER + if( val == REF_GL_CONTEXT_PROFILE_ES ) + SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1"); +#endif // SDL_HINT_OPENGL_ES_DRIVER + return SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, val ); +#endif #if SDL_VERSION_ATLEAST( 2, 0, 4 ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR ); #endif @@ -805,16 +903,9 @@ int GL_SetAttribute( int attr, int val ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RESET_NOTIFICATION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_NO_ERROR ); #endif - case REF_GL_CONTEXT_PROFILE_MASK: -#ifdef SDL_HINT_OPENGL_ES_DRIVER - if (val == REF_GL_CONTEXT_PROFILE_ES) - SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1"); -#endif // SDL_HINT_OPENGL_ES_DRIVER - return SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, val ); #undef MAP_REF_API_ATTRIBUTE_TO_SDL } - ASSERT( 0 ); return -1; } @@ -833,12 +924,15 @@ int GL_GetAttribute( int attr, int *val ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLEBUFFERS ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLESAMPLES ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ACCELERATED_VISUAL ); +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MAJOR_VERSION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MINOR_VERSION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_EGL ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_FLAGS ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE ); + MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_PROFILE_MASK ); +#endif #if SDL_VERSION_ATLEAST( 2, 0, 4 ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR ); #endif @@ -846,11 +940,9 @@ int GL_GetAttribute( int attr, int *val ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RESET_NOTIFICATION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_NO_ERROR ); #endif - MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_PROFILE_MASK ); #undef MAP_REF_API_ATTRIBUTE_TO_SDL } - ASSERT( 0 ); return 0; } @@ -865,18 +957,23 @@ R_Init_Video */ qboolean R_Init_Video( const int type ) { - SDL_DisplayMode displayMode; string safe; qboolean retval; - +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) + SDL_DisplayMode displayMode; SDL_GetCurrentDisplayMode(0, &displayMode); - glw_state.desktopBitsPixel = SDL_BITSPERPIXEL(displayMode.format); - glw_state.desktopWidth = displayMode.w; - glw_state.desktopHeight = displayMode.h; + refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format ); +#else + refState.desktopBitsPixel = 32; +#endif +#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) + SDL_VideoInit( "caca", 0 ); +#else #if !defined(_WIN32) SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" ); +#endif #endif R_InitVideoModes(); @@ -932,16 +1029,16 @@ qboolean R_Init_Video( const int type ) rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ) { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_DisplayMode displayMode; SDL_GetCurrentDisplayMode( 0, &displayMode ); - Con_Reportf( "R_ChangeDisplaySettings: Setting video mode to %dx%d %s\n", width, height, fullscreen ? "fullscreen" : "windowed" ); - // check our desktop attributes - glw_state.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format ); - glw_state.desktopWidth = displayMode.w; - glw_state.desktopHeight = displayMode.h; + refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format ); +#endif + + Con_Reportf( "R_ChangeDisplaySettings: Setting video mode to %dx%d %s\n", width, height, fullscreen ? "fullscreen" : "windowed" ); refState.fullScreen = fullscreen; @@ -958,6 +1055,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ) else { VID_RestoreScreenResolution(); +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( SDL_SetWindowFullscreen( host.hWnd, 0 ) ) return rserr_invalid_fullscreen; #if SDL_VERSION_ATLEAST( 2, 0, 5 ) @@ -965,7 +1063,9 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ) #endif SDL_SetWindowBordered( host.hWnd, SDL_TRUE ); SDL_SetWindowSize( host.hWnd, width, height ); - VID_SaveWindowSize( width, height ); + +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) + VID_SaveVideoMode( width, height ); } return rserr_ok; @@ -987,6 +1087,7 @@ qboolean VID_SetMode( void ) iScreenWidth = Cvar_VariableInteger( "width" ); iScreenHeight = Cvar_VariableInteger( "height" ); +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( iScreenWidth < VID_MIN_WIDTH || iScreenHeight < VID_MIN_HEIGHT ) // trying to get resolution automatically by default { @@ -1001,12 +1102,13 @@ qboolean VID_SetMode( void ) iScreenWidth = DEFAULT_MODE_WIDTH; iScreenHeight = DEFAULT_MODE_HEIGHT; #endif - - if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) ) - Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN ); - else - ClearBits( vid_fullscreen->flags, FCVAR_CHANGED ); } +#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) + + if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) ) + Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN ); + else + ClearBits( vid_fullscreen->flags, FCVAR_CHANGED ); SetBits( gl_vsync->flags, FCVAR_CHANGED ); fullscreen = Cvar_VariableInteger("fullscreen") != 0; @@ -1049,7 +1151,7 @@ R_Free_Video ================== */ void R_Free_Video( void ) -{ +{ GL_DeleteContext (); VID_DestroyWindow (); @@ -1057,6 +1159,10 @@ void R_Free_Video( void ) R_FreeVideoModes(); ref.dllFuncs.GL_ClearExtensions(); + +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) + SDL_VideoQuit(); +#endif } #endif // XASH_DEDICATED diff --git a/engine/platform/win32/sys_win.c b/engine/platform/win32/sys_win.c index d17745fc..bdf951ac 100644 --- a/engine/platform/win32/sys_win.c +++ b/engine/platform/win32/sys_win.c @@ -53,9 +53,9 @@ void Platform_ShellExecute( const char *path, const char *parms ) ShellExecute( NULL, "open", path, parms, NULL, SW_SHOW ); } -#ifdef XASH_DEDICATED +#if XASH_MESSAGEBOX == MSGBOX_WIN32 void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow ) { MessageBox( parentMainWindow ? host.hWnd : NULL, message, title, MB_OK|MB_SETFOREGROUND|MB_ICONSTOP ); } -#endif +#endif // XASH_MESSAGEBOX == MSGBOX_WIN32 From 5e8373fa4635346b4ca6e7b9ba80a1c0192f9ca2 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 26 Oct 2019 04:37:01 +0300 Subject: [PATCH 08/19] engine: slightly update RefAPI --- engine/ref_api.h | 2 ++ ref_gl/gl_image.c | 10 +++++----- ref_gl/gl_local.h | 7 ------- ref_gl/gl_opengl.c | 6 +++--- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/engine/ref_api.h b/engine/ref_api.h index 2566c2fb..778bcf4b 100644 --- a/engine/ref_api.h +++ b/engine/ref_api.h @@ -106,6 +106,8 @@ typedef struct ref_globals_s sortedface_t *draw_surfaces; // used for sorting translucent surfaces int max_surfaces; // max surfaces per submodel (for all models) size_t visbytes; // cluster size + + int desktopBitsPixel; } ref_globals_t; enum diff --git a/ref_gl/gl_image.c b/ref_gl/gl_image.c index 59ed1912..eb8b7a0b 100644 --- a/ref_gl/gl_image.c +++ b/ref_gl/gl_image.c @@ -687,25 +687,25 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan { if( haveColor && haveAlpha ) { - if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 ) + if( FBitSet( tex->flags, TF_ARB_16BIT ) || gpGlobals->desktopBitsPixel == 16 ) tex->format = GL_RGBA16F_ARB; else tex->format = GL_RGBA32F_ARB; } else if( haveColor ) { - if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 ) + if( FBitSet( tex->flags, TF_ARB_16BIT ) || gpGlobals->desktopBitsPixel == 16 ) tex->format = GL_RGB16F_ARB; else tex->format = GL_RGB32F_ARB; } else if( haveAlpha ) { - if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 ) + if( FBitSet( tex->flags, TF_ARB_16BIT ) || gpGlobals->desktopBitsPixel == 16 ) tex->format = GL_RG16F; else tex->format = GL_RG32F; } else { - if( FBitSet( tex->flags, TF_ARB_16BIT ) || glw_state.desktopBitsPixel == 16 ) + if( FBitSet( tex->flags, TF_ARB_16BIT ) || gpGlobals->desktopBitsPixel == 16 ) tex->format = GL_LUMINANCE16F_ARB; else tex->format = GL_LUMINANCE32F_ARB; } @@ -713,7 +713,7 @@ static void GL_SetTextureFormat( gl_texture_t *tex, pixformat_t format, int chan else { // NOTE: not all the types will be compressed - int bits = glw_state.desktopBitsPixel; + int bits = gpGlobals->desktopBitsPixel; switch( GL_CalcTextureSamples( channelMask )) { diff --git a/ref_gl/gl_local.h b/ref_gl/gl_local.h index b9ca8679..ace58f8c 100644 --- a/ref_gl/gl_local.h +++ b/ref_gl/gl_local.h @@ -691,13 +691,6 @@ typedef struct typedef struct { - void* context; // handle to GL rendering context - int safe; - - int desktopBitsPixel; - int desktopWidth; - int desktopHeight; - qboolean initialized; // OpenGL subsystem started qboolean extended; // extended context allows to GL_Debug } glwstate_t; diff --git a/ref_gl/gl_opengl.c b/ref_gl/gl_opengl.c index 68d8951a..6f1725d7 100644 --- a/ref_gl/gl_opengl.c +++ b/ref_gl/gl_opengl.c @@ -1041,7 +1041,7 @@ void GL_SetupAttributes( int safegl ) if( safegl < SAFE_NOACC ) gEngfuncs.GL_SetAttribute( REF_GL_ACCELERATED_VISUAL, 1 ); - gEngfuncs.Con_Printf( "bpp %d\n", glw_state.desktopBitsPixel ); + gEngfuncs.Con_Printf( "bpp %d\n", gpGlobals->desktopBitsPixel ); if( safegl < SAFE_NOSTENCIL ) gEngfuncs.GL_SetAttribute( REF_GL_STENCIL_SIZE, gl_stencilbits->value ); @@ -1056,13 +1056,13 @@ void GL_SetupAttributes( int safegl ) if( safegl < SAFE_NOCOLOR ) { - if( glw_state.desktopBitsPixel >= 24 ) + if( gpGlobals->desktopBitsPixel >= 24 ) { gEngfuncs.GL_SetAttribute( REF_GL_RED_SIZE, 8 ); gEngfuncs.GL_SetAttribute( REF_GL_GREEN_SIZE, 8 ); gEngfuncs.GL_SetAttribute( REF_GL_BLUE_SIZE, 8 ); } - else if( glw_state.desktopBitsPixel >= 16 ) + else if( gpGlobals->desktopBitsPixel >= 16 ) { gEngfuncs.GL_SetAttribute( REF_GL_RED_SIZE, 5 ); gEngfuncs.GL_SetAttribute( REF_GL_GREEN_SIZE, 6 ); From 7e9f90a09d3b35ce7bcdbd5b691d498a2db45d12 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 26 Oct 2019 15:26:26 +0300 Subject: [PATCH 09/19] public: fix detecting ARM on gcc3 --- public/build.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/build.h b/public/build.h index e52fccfc..88057f6a 100644 --- a/public/build.h +++ b/public/build.h @@ -56,7 +56,7 @@ GNU General Public License for more details. #elif defined(_MSC_VER) #define XASH_MSVC 1 #endif - + #if defined(_WIN64) #define XASH_WIN64 1 #endif @@ -142,13 +142,13 @@ GNU General Public License for more details. #elif defined __arm__ || defined _M_ARM #if defined _M_ARM #define XASH_ARM 7 // MSVC can only ARMv7 - #elif __ARM_ARCH == 7 + #elif __ARM_ARCH == 7 || __ARM_ARCH_7__ #define XASH_ARM 7 - #elif __ARM_ARCH == 6 + #elif __ARM_ARCH == 6 || __ARM_ARCH_6__ #define XASH_ARM 6 - #elif __ARM_ARCH == 5 + #elif __ARM_ARCH == 5 || __ARM_ARCH_5__ #define XASH_ARM 5 - #elif __ARM_ARCH == 4 + #elif __ARM_ARCH == 4 || __ARM_ARCH_4__ #define XASH_ARM 4 #else #error "Unknown ARM" From 7a7bca29918c60f3c33e00eb28298fcbe2eac019 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 26 Oct 2019 15:41:22 +0300 Subject: [PATCH 10/19] engine: wscript: always add librt on linux if it was checked before --- engine/wscript | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/wscript b/engine/wscript index 6910e5f3..38f9826f 100644 --- a/engine/wscript +++ b/engine/wscript @@ -41,6 +41,8 @@ def configure(conf): elif conf.options.SDL12: conf.define('XASH_SDL', 12) conf.check_cfg(package='sdl', args='--cflags --libs', uselib_store='SDL2' ) + if conf.env.DEST_OS == 'linux': + conf.check_cc( lib='rt' ) conf.env.HAVE_SDL2 = True else: conf.load('sdl2') @@ -104,7 +106,6 @@ def build(bld): 'client/*.c', 'client/vgui/*.c', 'client/avi/*.c']) - # HACK: public headers must be put before common, so we don't get wrong mathlib included includes = ['common', 'server', 'client', 'client/vgui', '.', '../public', '../common', '../pm_shared' ] From aa6674b03259a305ea2d4d310825d5750ea2abb8 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 26 Oct 2019 15:42:00 +0300 Subject: [PATCH 11/19] engine: support compiling with gcc3 --- common/com_model.h | 4 +-- common/const.h | 1 - common/r_efx.h | 3 +- common/xash3d_types.h | 2 -- engine/client/client.h | 3 +- engine/client/vox.h | 6 ++-- engine/common/common.h | 12 ++------ engine/common/filesystem.c | 8 +++--- engine/common/mod_local.h | 5 +--- engine/common/net_buffer.h | 4 +-- engine/common/net_encode.h | 46 ++++++++++++++++--------------- engine/common/soundlib/soundlib.h | 4 +-- engine/platform/platform.h | 5 ++-- ref_gl/gl_local.h | 2 +- 14 files changed, 45 insertions(+), 60 deletions(-) diff --git a/common/com_model.h b/common/com_model.h index f31a754a..535b81a4 100644 --- a/common/com_model.h +++ b/common/com_model.h @@ -232,7 +232,7 @@ typedef struct mextrasurf_s int reserved[32]; // just for future expansions or mod-makers } mextrasurf_t; -typedef struct msurface_s +struct msurface_s { int visframe; // should be drawn when node is crossed @@ -264,7 +264,7 @@ typedef struct msurface_s color24 *samples; // note: this is the actual lightmap data for this surface decal_t *pdecals; -} msurface_t; +}; typedef struct hull_s { diff --git a/common/const.h b/common/const.h index b6b96b6a..5cbf8988 100644 --- a/common/const.h +++ b/common/const.h @@ -729,7 +729,6 @@ enum typedef int func_t; typedef int string_t; -typedef unsigned char byte; typedef unsigned short word; #include "xash3d_types.h" diff --git a/common/r_efx.h b/common/r_efx.h index 8cffd850..b921e383 100644 --- a/common/r_efx.h +++ b/common/r_efx.h @@ -84,7 +84,6 @@ color24 gTracerColors[] = #define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) #define FTENT_SCALE 0x00100000 // An experiment -typedef struct tempent_s TEMPENTITY; struct pmtrace_s; typedef struct tempent_s { @@ -99,7 +98,7 @@ typedef struct tempent_s int hitSound; void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr ); void (*callback)( struct tempent_s *ent, float frametime, float currenttime ); - TEMPENTITY *next; + struct tempent_s *next; int priority; short clientIndex; // if attached, this is the index of the client to stick to // if COLLIDEALL, this is the index of the client to ignore diff --git a/common/xash3d_types.h b/common/xash3d_types.h index ac86cdea..5a353351 100644 --- a/common/xash3d_types.h +++ b/common/xash3d_types.h @@ -11,9 +11,7 @@ typedef unsigned char byte; typedef int sound_t; typedef float vec_t; -typedef vec_t vec2_t[2]; typedef vec_t vec3_t[3]; -typedef vec_t vec4_t[4]; typedef vec_t quat_t[4]; typedef byte rgba_t[4]; // unsigned byte colorpack typedef byte rgb_t[3]; // unsigned byte colorpack diff --git a/engine/client/client.h b/engine/client/client.h index fa5ec2a6..caceb099 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -16,6 +16,7 @@ GNU General Public License for more details. #ifndef CLIENT_H #define CLIENT_H +#include "xash3d_types.h" #include "mathlib.h" #include "cdll_int.h" #include "menu_int.h" @@ -38,8 +39,6 @@ GNU General Public License for more details. #define SPR_HUDSPRITE 1 // hud sprite #define SPR_MAPSPRITE 2 // contain overview.bmp that diced into frames 128x128 -typedef int sound_t; - //============================================================================= typedef struct netbandwithgraph_s { diff --git a/engine/client/vox.h b/engine/client/vox.h index 7276ee45..8e6e557b 100644 --- a/engine/client/vox.h +++ b/engine/client/vox.h @@ -41,8 +41,8 @@ typedef struct float length; } sentence_t; -typedef struct channel_s channel_t; -void VOX_LoadWord( channel_t *pchan ); -void VOX_FreeWord( channel_t *pchan ); +struct channel_s; +void VOX_LoadWord( struct channel_s *pchan ); +void VOX_FreeWord( struct channel_s *pchan ); #endif diff --git a/engine/common/common.h b/engine/common/common.h index c5f9d46b..3b15c8b4 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -829,7 +829,7 @@ void HPAK_FlushHostQueue( void ); // shared calls struct physent_s; -typedef struct sv_client_s sv_client_t; +struct sv_client_s; typedef struct sizebuf_s sizebuf_t; qboolean CL_IsInGame( void ); qboolean CL_IsInMenu( void ); @@ -858,7 +858,7 @@ void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int en void Log_Printf( const char *fmt, ... ) _format( 1 ); void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 ); qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent ); -void SV_BroadcastPrintf( sv_client_t *ignore, char *fmt, ... ) _format( 2 ); +void SV_BroadcastPrintf( struct sv_client_s *ignore, char *fmt, ... ) _format( 2 ); int R_CreateDecalList( struct decallist_s *pList ); void R_ClearAllDecals( void ); void CL_ClearStaticEntities( void ); @@ -960,14 +960,6 @@ void ID_Init( void ); const char *ID_GetMD5( void ); void GAME_EXPORT ID_SetCustomClientID( const char *id ); -// -// sequence.c -// -typedef struct sequenceEntry_ sequenceEntry_s; -typedef struct sentenceEntry_ sentenceEntry_s; -sequenceEntry_s *Sequence_Get( const char *fileName, const char *entryName ); -sentenceEntry_s *Sequence_PickSentence( const char *groupName, int pickMethod, int *picked ); - // // masterlist.c // diff --git a/engine/common/filesystem.c b/engine/common/filesystem.c index 0eaacbb3..3560e068 100644 --- a/engine/common/filesystem.c +++ b/engine/common/filesystem.c @@ -74,7 +74,7 @@ typedef struct wadtype_s signed char type; } wadtype_t; -typedef struct file_s +struct file_s { int handle; // file descriptor fs_offset_t real_length; // uncompressed file size (for files opened in "read" mode) @@ -85,9 +85,9 @@ typedef struct file_s // contents buffer fs_offset_t buff_ind, buff_len; // buffer current index and length byte buff[FILE_BUFF_SIZE]; // intermediate buffer -} file_t; +}; -typedef struct wfile_s +struct wfile_s { string filename; int infotableofs; @@ -96,7 +96,7 @@ typedef struct wfile_s file_t *handle; dlumpinfo_t *lumps; time_t filetime; -} wfile_t; +}; typedef struct pack_s { diff --git a/engine/common/mod_local.h b/engine/common/mod_local.h index 386a3057..7b1d8cdf 100644 --- a/engine/common/mod_local.h +++ b/engine/common/mod_local.h @@ -20,6 +20,7 @@ GNU General Public License for more details. #include "edict.h" #include "eiface.h" #include "ref_api.h" +#include "studio.h" #define LM_SAMPLE_SIZE 16 #define LM_SAMPLE_EXTRASIZE 8 @@ -172,10 +173,6 @@ void Mod_ReleaseHullPolygons( void ); // // mod_studio.c // -typedef struct studiohdr_s studiohdr_t; -typedef struct mstudioseqdesc_s mstudioseqdesc_t; -typedef struct mstudiobone_s mstudiobone_t; -typedef struct mstudioanim_s mstudioanim_t; void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded ); void Mod_UnloadStudioModel( model_t *mod ); void Mod_InitStudioAPI( void ); diff --git a/engine/common/net_buffer.h b/engine/common/net_buffer.h index 53eb33ff..0d0af632 100644 --- a/engine/common/net_buffer.h +++ b/engine/common/net_buffer.h @@ -35,7 +35,7 @@ _inline int BitByte( int bits ) return PAD_NUMBER( bits, 8 ) >> 3; } -typedef struct sizebuf_s +struct sizebuf_s { qboolean bOverflow; // overflow reading or writing const char *pDebugName; // buffer name (pointer to const name) @@ -43,7 +43,7 @@ typedef struct sizebuf_s byte *pData; int iCurBit; int nDataBits; -} sizebuf_t; +}; #define MSG_StartReading MSG_StartWriting #define MSG_GetNumBytesRead MSG_GetNumBytesWritten diff --git a/engine/common/net_encode.h b/engine/common/net_encode.h index 9eeb2b58..28484143 100644 --- a/engine/common/net_encode.h +++ b/engine/common/net_encode.h @@ -16,6 +16,8 @@ GNU General Public License for more details. #ifndef NET_ENCODE_H #define NET_ENCODE_H +#include "eiface.h" + #define DT_BYTE BIT( 0 ) // A byte #define DT_SHORT BIT( 1 ) // 2 byte field #define DT_FLOAT BIT( 2 ) // A floating point field @@ -62,7 +64,7 @@ typedef struct } delta_field_t; // one field -typedef struct delta_s +struct delta_s { const char *name; int offset; // in bytes @@ -72,9 +74,9 @@ typedef struct delta_s float post_multiplier; // for DEFINE_DELTA_POST int bits; // how many bits we send\receive qboolean bInactive; // unsetted by user request -} delta_t; +}; -typedef void (*pfnDeltaEncode)( delta_t *pFields, const byte *from, const byte *to ); +typedef void (*pfnDeltaEncode)( struct delta_s *pFields, const byte *from, const byte *to ); typedef struct { @@ -113,24 +115,24 @@ void Delta_ParseTableField( sizebuf_t *msg ); // encode routines -typedef struct entity_state_s entity_state_t; -typedef struct usercmd_s usercmd_t; -typedef struct event_args_s event_args_t; -typedef struct movevars_s movevars_t; -typedef struct clientdata_s clientdata_t; -typedef struct weapon_data_s weapon_data_t; -void MSG_WriteDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to ); -void MSG_ReadDeltaUsercmd( sizebuf_t *msg, usercmd_t *from, usercmd_t *to ); -void MSG_WriteDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to ); -void MSG_ReadDeltaEvent( sizebuf_t *msg, event_args_t *from, event_args_t *to ); -qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to ); -void MSG_ReadDeltaMovevars( sizebuf_t *msg, movevars_t *from, movevars_t *to ); -void MSG_WriteClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, float timebase ); -void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, float timebase ); -void MSG_WriteWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, float timebase, int index ); -void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, float timebase ); -void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, int type, float tbase, int ofs ); -qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int num, int type, float timebase ); -int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean player, float timebase ); +struct entity_state_s; +struct usercmd_s; +struct event_args_s; +struct movevars_s; +struct clientdata_s; +struct weapon_data_s; +void MSG_WriteDeltaUsercmd( sizebuf_t *msg, struct usercmd_s *from, struct usercmd_s *to ); +void MSG_ReadDeltaUsercmd( sizebuf_t *msg, struct usercmd_s *from, struct usercmd_s *to ); +void MSG_WriteDeltaEvent( sizebuf_t *msg, struct event_args_s *from, struct event_args_s *to ); +void MSG_ReadDeltaEvent( sizebuf_t *msg, struct event_args_s *from, struct event_args_s *to ); +qboolean MSG_WriteDeltaMovevars( sizebuf_t *msg, struct movevars_s *from, struct movevars_s *to ); +void MSG_ReadDeltaMovevars( sizebuf_t *msg, struct movevars_s *from, struct movevars_s *to ); +void MSG_WriteClientData( sizebuf_t *msg, struct clientdata_s *from, struct clientdata_s *to, float timebase ); +void MSG_ReadClientData( sizebuf_t *msg, struct clientdata_s *from, struct clientdata_s *to, float timebase ); +void MSG_WriteWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, float timebase, int index ); +void MSG_ReadWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, float timebase ); +void MSG_WriteDeltaEntity( struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, float tbase, int ofs ); +qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, struct entity_state_s *from, struct entity_state_s *to, int num, int type, float timebase ); +int Delta_TestBaseline( struct entity_state_s *from, struct entity_state_s *to, qboolean player, float timebase ); #endif//NET_ENCODE_H diff --git a/engine/common/soundlib/soundlib.h b/engine/common/soundlib/soundlib.h index 81483177..686d50b1 100644 --- a/engine/common/soundlib/soundlib.h +++ b/engine/common/soundlib/soundlib.h @@ -60,7 +60,7 @@ typedef struct sndlib_s int cmd_flags; } sndlib_t; -typedef struct stream_s +struct stream_s { const streamfmt_t *format; // streamformat to operate @@ -77,7 +77,7 @@ typedef struct stream_s char temp[OUTBUF_SIZE]; // mpeg decoder stuff size_t pos; // actual track position (or actual buffer remains) int buffsize; // cached buffer size -} stream_t; +}; /* ======================================================================== diff --git a/engine/platform/platform.h b/engine/platform/platform.h index 21772b80..cc7857b8 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -103,15 +103,14 @@ typedef enum rserr_unknown } rserr_t; -typedef struct vidmode_s vidmode_t; - +struct vidmode_s; // Window qboolean R_Init_Video( const int type ); void R_Free_Video( void ); qboolean VID_SetMode( void ); rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ); int R_MaxVideoModes( void ); -vidmode_t*R_GetVideoMode( int num ); +struct vidmode_s *R_GetVideoMode( int num ); void* GL_GetProcAddress( const char *name ); // RenderAPI requirement void GL_UpdateSwapInterval( void ); int GL_SetAttribute( int attr, int val ); diff --git a/ref_gl/gl_local.h b/ref_gl/gl_local.h index ace58f8c..9d49cd8c 100644 --- a/ref_gl/gl_local.h +++ b/ref_gl/gl_local.h @@ -33,6 +33,7 @@ GNU General Public License for more details. #include "pm_movevars.h" //#include "cvar.h" #include "gl_export.h" +#include "wadfile.h" #ifndef offsetof #define offsetof(s,m) (size_t)&(((s *)0)->m) @@ -480,7 +481,6 @@ void R_AliasInit( void ); // // gl_warp.c // -typedef struct mip_s mip_t; void R_InitSkyClouds( mip_t *mt, struct texture_s *tx, qboolean custom_palette ); void R_AddSkyBoxSurface( msurface_t *fa ); void R_ClearSkyBox( void ); From 2958b14cc218563094915e4eb483b304e59d5c5c Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 28 Oct 2019 01:46:16 +0300 Subject: [PATCH 12/19] engine: platform: magx: add pre-init platform-specific hook --- engine/platform/magx/sys_magx.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 engine/platform/magx/sys_magx.cpp diff --git a/engine/platform/magx/sys_magx.cpp b/engine/platform/magx/sys_magx.cpp new file mode 100644 index 00000000..432c4970 --- /dev/null +++ b/engine/platform/magx/sys_magx.cpp @@ -0,0 +1,25 @@ +/* +sys_magx.cpp - MotoMAGX system utils +Copyright (C) 2019 a1batross + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +*/ +#include "platform/platform.h" +#include + +typedef void (*pfnChangeGame)( const char *progname ); +extern "C" int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func ); + +extern "C" int EXPORT Platform_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func ) +{ + ZApplication app( argc, argv ); + return Host_Main( argc, argv, progname, bChangeGame, func ); +} From 6aa61657e03e0e50d0bc53de93a00a17d8643f07 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 28 Oct 2019 01:46:35 +0300 Subject: [PATCH 13/19] game_launch: check for Platform_Main before Host_Main --- game_launch/game.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/game_launch/game.cpp b/game_launch/game.cpp index d8bc8152..7d226372 100644 --- a/game_launch/game.cpp +++ b/game_launch/game.cpp @@ -92,7 +92,11 @@ static void Sys_LoadEngine( void ) Xash_Error("Unable to load the " XASHLIB ": %s", dlerror() ); } - if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Host_Main" )) == NULL ) + if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Platform_Main" )) == NULL ) + { + // silently ignore absence of platform-specific init + } + else if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Host_Main" )) == NULL ) { Xash_Error( XASHLIB " missed 'Host_Main' export: %s", dlerror() ); } From 9aff6ca63379f39d117fcdf6c675f200e710f1dd Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 28 Oct 2019 01:47:18 +0300 Subject: [PATCH 14/19] engine: wscript: support building for MotoMAGX --- engine/wscript | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/engine/wscript b/engine/wscript index 38f9826f..7963e047 100644 --- a/engine/wscript +++ b/engine/wscript @@ -20,12 +20,26 @@ def options(opt): grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False, help = 'enable custom swap allocator. For devices with no swap support') + grp.add_option('--enable-magx', action = 'store_true', dest = 'MAGX', default = False, + help = 'enable targetting for MotoMAGX phones [default: %default]') + grp.add_option('--enable-legacy-sdl', action = 'store_true', dest = 'SDL12', default = False, help = 'enable using SDL1.2 instead of SDL2(not recommended) [default: %default') opt.load('sdl2') def configure(conf): + conf.env.MAGX = conf.options.MAGX + if conf.options.MAGX: + # useless to change toolchain path, as toolchain meant to be placed in this path + toolchain_path = '/opt/toolchains/motomagx/arm-eabi2/lib/' + conf.env.INCLUDES_MAGX = [toolchain_path + i for i in ['ezx-z6/include', 'qt-2.3.8/include']] + conf.env.LIBPATH_MAGX = [toolchain_path + i for i in ['ezx-z6/lib', 'qt-2.3.8/lib']] + conf.env.LINKFLAGS_MAGX = ['-Wl,-rpath-link=' + i for i in conf.env.LIBPATH_MAGX] + for lib in ['qte-mt', 'ezxappbase', 'ezxpm', 'log_util']: + conf.check_cc(lib=lib, use='MAGX', uselib_store='MAGX') + conf.options.SDL12 = True + # check for dedicated server build if conf.options.DEDICATED: if conf.env.DEST_OS == 'linux': @@ -69,6 +83,7 @@ def configure(conf): conf.define_cond('PSAPI_VERSION', conf.env.DEST_OS == 'win32') # will be defined as 1 def build(bld): + is_cxx_link = False libs = [ 'public' ] source = bld.path.ant_glob([ 'common/*.c', @@ -96,6 +111,11 @@ def build(bld): libs.append('SDL2') source += bld.path.ant_glob(['platform/sdl/*.c']) + if bld.env.MAGX: + libs.append('MAGX') + source += bld.path.ant_glob(['platform/magx/*.cpp']) + is_cxx_link = True + if bld.env.DEST_OS == 'android': libs += ['LOG', 'EGL', 'ANDROID'] source += bld.path.ant_glob(['platform/android/*.cpp', 'platform/android/*.c', 'platform/linux/*.c']) @@ -112,10 +132,10 @@ def build(bld): if bld.env.SINGLE_BINARY: install_path = bld.env.BINDIR - features = 'c cprogram' + features = ['c', 'cxxprogram' if is_cxx_link else 'cprogram'] else: install_path = bld.env.LIBDIR - features = 'c cshlib' + features = ['c', 'cxxshlib' if is_cxx_link else 'cshlib'] bld(source = source, target = 'xash', From 90038d29248e8c63e1f449df2c390c24410a2e98 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 2 Nov 2019 08:53:31 +0300 Subject: [PATCH 15/19] common: fix broken build --- common/com_model.h | 4 +--- common/xash3d_types.h | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/com_model.h b/common/com_model.h index 535b81a4..1372cd07 100644 --- a/common/com_model.h +++ b/common/com_model.h @@ -16,11 +16,9 @@ GNU General Public License for more details. #ifndef COM_MODEL_H #define COM_MODEL_H +#include "xash3d_types.h" #include "bspfile.h" // we need some declarations from it -typedef vec_t vec2_t[2]; -typedef vec_t vec4_t[4]; - /* ============================================================================== diff --git a/common/xash3d_types.h b/common/xash3d_types.h index 5a353351..ac86cdea 100644 --- a/common/xash3d_types.h +++ b/common/xash3d_types.h @@ -11,7 +11,9 @@ typedef unsigned char byte; typedef int sound_t; typedef float vec_t; +typedef vec_t vec2_t[2]; typedef vec_t vec3_t[3]; +typedef vec_t vec4_t[4]; typedef vec_t quat_t[4]; typedef byte rgba_t[4]; // unsigned byte colorpack typedef byte rgb_t[3]; // unsigned byte colorpack From 2062e55c6a8e03dca59177254f77fca11de47505 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 2 Nov 2019 08:54:08 +0300 Subject: [PATCH 16/19] lowmemory: cut up netgraph buffers --- engine/client/cl_netgraph.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engine/client/cl_netgraph.c b/engine/client/cl_netgraph.c index d20a0de5..ed40ed5a 100644 --- a/engine/client/cl_netgraph.c +++ b/engine/client/cl_netgraph.c @@ -16,7 +16,11 @@ GNU General Public License for more details. #include "common.h" #include "client.h" +#if XASH_LOW_MEMORY #define NET_TIMINGS 1024 +#else +#define NET_TIMINGS 64 +#endif #define NET_TIMINGS_MASK (NET_TIMINGS - 1) #define LATENCY_AVG_FRAC 0.5f #define FRAMERATE_AVG_FRAC 0.5f From 1f308a43c87dfdbd49c8582cd0cbfb60ca380812 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 2 Nov 2019 08:54:58 +0300 Subject: [PATCH 17/19] engine: fix build after lowmemory rebase --- engine/common/common.c | 1 + engine/common/host.c | 7 +++---- engine/platform/sdl/events.c | 6 ++---- engine/platform/sdl/vid_sdl.c | 35 +++++++++++++++++++---------------- engine/wscript | 2 ++ 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/engine/common/common.c b/engine/common/common.c index 2656e25d..2d937c84 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -19,6 +19,7 @@ GNU General Public License for more details. #include "const.h" #include "client.h" #include "library.h" +#include "sequence.h" static const char *file_exts[] = { diff --git a/engine/common/host.c b/engine/common/host.c index d530e110..8f5e9145 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -323,7 +323,9 @@ void Host_MemStats_f( void ) void Host_Minimize_f( void ) { +#ifdef XASH_SDL if( host.hWnd ) SDL_MinimizeWindow( host.hWnd ); +#endif } /* @@ -812,14 +814,11 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha #endif #ifdef XASH_SDL - // should work even if it failed - SDL_Init( SDL_INIT_TIMER ); - #ifndef SDL_INIT_EVENTS #define SDL_INIT_EVENTS 0 #endif - if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) ) + if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS ) ) { Sys_Warn( "SDL_Init failed: %s", SDL_GetError() ); host.type = HOST_DEDICATED; diff --git a/engine/platform/sdl/events.c b/engine/platform/sdl/events.c index 1824b34f..4b0884e2 100644 --- a/engine/platform/sdl/events.c +++ b/engine/platform/sdl/events.c @@ -568,14 +568,12 @@ static void SDLash_EventFilter( SDL_Event *event ) SDLash_ActiveEvent( false ); break; case SDL_WINDOWEVENT_RESIZED: - case SDL_WINDOWEVENT_MAXIMIZED: { int w = VID_MIN_WIDTH, h = VID_MIN_HEIGHT; if( vid_fullscreen->value ) break; - SDL_GL_GetDrawableSize( host.hWnd, &w, &h ); - R_SaveVideoMode( w, h ); + VID_SaveWindowSize( w, h ); SCR_VidInit(); // tell the client.dll that vid_mode has changed break; } @@ -584,7 +582,7 @@ static void SDLash_EventFilter( SDL_Event *event ) } #else case SDL_VIDEORESIZE: - R_SaveVideoMode( event->resize.w, event->resize.h ); + VID_SaveWindowSize( event->resize.w, event->resize.h ); SCR_VidInit(); break; // tell the client.dll that vid_mode has changed case SDL_ACTIVEEVENT: diff --git a/engine/platform/sdl/vid_sdl.c b/engine/platform/sdl/vid_sdl.c index ae727f75..1177a6f3 100644 --- a/engine/platform/sdl/vid_sdl.c +++ b/engine/platform/sdl/vid_sdl.c @@ -300,9 +300,11 @@ static void R_InitVideoModes( void ) num_vidmodes++; } #else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - SDL_Rect **modes = SDL_ListModes( NULL, SDL_FULLSCREEN ); + SDL_Rect **modes; int len = 0, i = 0, j; + modes = SDL_ListModes( NULL, SDL_FULLSCREEN ); + if( !modes || modes == (void*)-1 ) return; @@ -513,10 +515,12 @@ void VID_SaveWindowSize( int width, int height ) int render_w = width, render_h = height; uint rotate = vid_rotate->value; +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( !glw_state.software ) SDL_GL_GetDrawableSize( host.hWnd, &render_w, &render_h ); else SDL_RenderSetLogicalSize( sw.renderer, width, height ); +#endif if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale->value, vid_scale->value ) ) { @@ -570,7 +574,7 @@ static qboolean VID_SetScreenResolution( int width, int height ) SDL_SetWindowGrab( host.hWnd, SDL_TRUE ); SDL_SetWindowSize( host.hWnd, got.w, got.h ); - VID_SaveWindowSize( gow.w, got.h ); + VID_SaveWindowSize( got.w, got.h ); #else VID_SaveWindowSize( width, height ); #endif @@ -774,7 +778,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) if( fullscreen ) { - // flags |= SDL_FULLSCREEN; + flags |= SDL_FULLSCREEN|SDL_HWSURFACE; } if( glw_state.software ) @@ -788,7 +792,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) while( glw_state.safe >= SAFE_NO && glw_state.safe < SAFE_LAST ) { - host.hWnd = sw.surf = SDL_SetVideoMode( width, height, 0, flags ); + host.hWnd = sw.surf = SDL_SetVideoMode( width, height, 16, flags ); // we have window, exit loop if( host.hWnd ) @@ -815,7 +819,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) #endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) - VID_SaveVideoMode( width, height ); + VID_SaveWindowSize( width, height ); return true; } @@ -964,19 +968,13 @@ qboolean R_Init_Video( const int type ) SDL_GetCurrentDisplayMode(0, &displayMode); refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format ); #else - refState.desktopBitsPixel = 32; + refState.desktopBitsPixel = 16; #endif -#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) - SDL_VideoInit( "caca", 0 ); -#else -#if !defined(_WIN32) +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) && !defined(_WIN32) SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" ); #endif -#endif - - R_InitVideoModes(); // must be initialized before creating window #ifdef _WIN32 @@ -1022,6 +1020,8 @@ qboolean R_Init_Video( const int type ) break; } + R_InitVideoModes(); + host.renderinfo_changed = false; return true; @@ -1065,7 +1065,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ) SDL_SetWindowSize( host.hWnd, width, height ); #endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) - VID_SaveVideoMode( width, height ); + VID_SaveWindowSize( width, height ); } return rserr_ok; @@ -1087,10 +1087,10 @@ qboolean VID_SetMode( void ) iScreenWidth = Cvar_VariableInteger( "width" ); iScreenHeight = Cvar_VariableInteger( "height" ); -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( iScreenWidth < VID_MIN_WIDTH || iScreenHeight < VID_MIN_HEIGHT ) // trying to get resolution automatically by default { +#if SDL_VERSION_ATLEAST( 2, 0, 0 ) #if !defined( DEFAULT_MODE_WIDTH ) || !defined( DEFAULT_MODE_HEIGHT ) SDL_DisplayMode mode; @@ -1102,8 +1102,11 @@ qboolean VID_SetMode( void ) iScreenWidth = DEFAULT_MODE_WIDTH; iScreenHeight = DEFAULT_MODE_HEIGHT; #endif - } +#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) + iScreenWidth = 320; + iScreenHeight = 240; #endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) + } if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) ) Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN ); diff --git a/engine/wscript b/engine/wscript index 7963e047..24177031 100644 --- a/engine/wscript +++ b/engine/wscript @@ -15,8 +15,10 @@ def options(opt): grp.add_option('--fbdev', action = 'store_true', dest = 'FBDEV_SW', default = False, help = 'build fbdev-only software-only engine') + grp.add_option('--disable-async-resolve', action = 'store_true', dest = 'NO_ASYNC_RESOLVE', default = False, help = 'disable asynchronous name resolution') + grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False, help = 'enable custom swap allocator. For devices with no swap support') From dfed24c29059e720c5ea05473373420941e64abf Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 2 Nov 2019 08:55:14 +0300 Subject: [PATCH 18/19] public: build: add new ARMv6 detect macro --- public/build.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/build.h b/public/build.h index 88057f6a..c8bcc805 100644 --- a/public/build.h +++ b/public/build.h @@ -144,7 +144,7 @@ GNU General Public License for more details. #define XASH_ARM 7 // MSVC can only ARMv7 #elif __ARM_ARCH == 7 || __ARM_ARCH_7__ #define XASH_ARM 7 - #elif __ARM_ARCH == 6 || __ARM_ARCH_6__ + #elif __ARM_ARCH == 6 || __ARM_ARCH_6__ || __ARM_ARCH_6J__ #define XASH_ARM 6 #elif __ARM_ARCH == 5 || __ARM_ARCH_5__ #define XASH_ARM 5 From a46e459124f5cb4812078c12ef70e13c4cad989b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 2 Nov 2019 08:55:30 +0300 Subject: [PATCH 19/19] game_launch: fix start up --- game_launch/game.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/game_launch/game.cpp b/game_launch/game.cpp index 7d226372..e5517454 100644 --- a/game_launch/game.cpp +++ b/game_launch/game.cpp @@ -92,11 +92,8 @@ static void Sys_LoadEngine( void ) Xash_Error("Unable to load the " XASHLIB ": %s", dlerror() ); } - if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Platform_Main" )) == NULL ) - { - // silently ignore absence of platform-specific init - } - else if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Host_Main" )) == NULL ) + if(( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Platform_Main" )) == NULL && + ( Xash_Main = (pfnInit)GetProcAddress( hEngine, "Host_Main" )) == NULL ) { Xash_Error( XASHLIB " missed 'Host_Main' export: %s", dlerror() ); }