@@ -182,6 +182,8 @@ template<gameid_t ID>
182182struct gamedef_q1_like_t : public gamedef_t
183183{
184184public:
185+ bool allows_hl_contents = false ;
186+
185187 explicit gamedef_q1_like_t (const char *friendly_name = " quake" , const char *base_dir = " ID1" )
186188 : gamedef_t(friendly_name, base_dir)
187189 {
@@ -243,6 +245,20 @@ struct gamedef_q1_like_t : public gamedef_t
243245 case CONTENTS_WATER: return contentflags_t::make (EWT_VISCONTENTS_WATER);
244246 case CONTENTS_EMPTY: return contentflags_t::make (EWT_VISCONTENTS_EMPTY);
245247 }
248+
249+ if (allows_hl_contents) {
250+ // clang-format off
251+ switch (native) {
252+ case HL_CONTENTS_CURRENT_0: return contentflags_t::make (EWT_VISCONTENTS_WATER | EWT_CFLAG_CURRENT_0);
253+ case HL_CONTENTS_CURRENT_90: return contentflags_t::make (EWT_VISCONTENTS_WATER | EWT_CFLAG_CURRENT_90);
254+ case HL_CONTENTS_CURRENT_180: return contentflags_t::make (EWT_VISCONTENTS_WATER | EWT_CFLAG_CURRENT_180);
255+ case HL_CONTENTS_CURRENT_270: return contentflags_t::make (EWT_VISCONTENTS_WATER | EWT_CFLAG_CURRENT_270);
256+ case HL_CONTENTS_CURRENT_UP: return contentflags_t::make (EWT_VISCONTENTS_WATER | EWT_CFLAG_CURRENT_UP);
257+ case HL_CONTENTS_CURRENT_DOWN: return contentflags_t::make (EWT_VISCONTENTS_WATER | EWT_CFLAG_CURRENT_DOWN);
258+ }
259+ // clang-format on
260+ }
261+
246262 throw std::invalid_argument (fmt::format (" create_contents_from_native: unknown Q1 contents {}" , native));
247263 }
248264
@@ -265,6 +281,21 @@ struct gamedef_q1_like_t : public gamedef_t
265281 } else if (contents.flags & EWT_VISCONTENTS_SLIME) {
266282 return CONTENTS_SLIME;
267283 } else if (contents.flags & EWT_VISCONTENTS_WATER) {
284+ if (allows_hl_contents) {
285+ if (contents.flags & EWT_CFLAG_CURRENT_0)
286+ return HL_CONTENTS_CURRENT_0;
287+ if (contents.flags & EWT_CFLAG_CURRENT_90)
288+ return HL_CONTENTS_CURRENT_90;
289+ if (contents.flags & EWT_CFLAG_CURRENT_180)
290+ return HL_CONTENTS_CURRENT_180;
291+ if (contents.flags & EWT_CFLAG_CURRENT_270)
292+ return HL_CONTENTS_CURRENT_270;
293+ if (contents.flags & EWT_CFLAG_CURRENT_UP)
294+ return HL_CONTENTS_CURRENT_UP;
295+ if (contents.flags & EWT_CFLAG_CURRENT_DOWN)
296+ return HL_CONTENTS_CURRENT_DOWN;
297+ }
298+
268299 return CONTENTS_WATER;
269300 } else if (contents.flags & EWT_VISCONTENTS_MIST) {
270301 throw std::invalid_argument (" EWT_VISCONTENTS_MIST not representable in Q1" );
@@ -328,6 +359,29 @@ struct gamedef_q1_like_t : public gamedef_t
328359 liquid_flags = EWT_CFLAG_DETAIL | EWT_CFLAG_TRANSLUCENT;
329360 }
330361
362+ // HL water with current
363+ if (allows_hl_contents) {
364+ contents_int_t current_flag = 0 ;
365+
366+ if (string_istarts_with (texname, " !cur_0" )) {
367+ current_flag = EWT_CFLAG_CURRENT_0;
368+ } else if (string_istarts_with (texname, " !cur_90" )) {
369+ current_flag = EWT_CFLAG_CURRENT_90;
370+ } else if (string_istarts_with (texname, " !cur_180" )) {
371+ current_flag = EWT_CFLAG_CURRENT_180;
372+ } else if (string_istarts_with (texname, " !cur_270" )) {
373+ current_flag = EWT_CFLAG_CURRENT_270;
374+ } else if (string_istarts_with (texname, " !cur_up" )) {
375+ current_flag = EWT_CFLAG_CURRENT_UP;
376+ } else if (string_istarts_with (texname, " !cur_dwn" )) {
377+ current_flag = EWT_CFLAG_CURRENT_DOWN;
378+ }
379+
380+ if (current_flag) {
381+ return contentflags_t::make (EWT_VISCONTENTS_WATER | liquid_flags | current_flag);
382+ }
383+ }
384+
331385 if (!Q_strncasecmp (texname.data () + 1 , " lava" , 4 )) {
332386 return contentflags_t::make (EWT_VISCONTENTS_LAVA | liquid_flags);
333387 } else if (!Q_strncasecmp (texname.data () + 1 , " slime" , 5 )) {
@@ -466,6 +520,7 @@ struct gamedef_hl_t : public gamedef_q1_like_t<GAME_HALF_LIFE>
466520 : gamedef_q1_like_t (" halflife" , " VALVE" )
467521 {
468522 has_rgb_lightmap = true ;
523+ allows_hl_contents = true ;
469524 }
470525
471526 std::span<const aabb3d> get_hull_sizes () const override
0 commit comments