News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

[PATCH] call display_after for all ways in display_obj_quick_and_dirty

Started by Philip, August 18, 2014, 11:37:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Philip

...not just for those that happen to be on squares with capacity==1. This makes the quick and dirty version behave more like display_obj_bg and fixes tooltips for ways.


diff --git a/dataobj/objlist.cc b/dataobj/objlist.cc
index 7d3bd5e..5fed76a 100644
--- a/dataobj/objlist.cc
+++ b/dataobj/objlist.cc
@@ -1131,15 +1131,18 @@ void objlist_t::display_obj_quick_and_dirty( const sint16 xpos, const sint16 ypo
                if(start_offset==0) {
#ifdef MULTI_THREAD
                        obj.one->display( xpos, ypos, clip_num );
-                       obj.one->display_after(xpos, ypos, clip_num );
#else
                        obj.one->display( xpos, ypos );
-                       obj.one->display_after( xpos, ypos, is_global );
-                       if(  is_global  ) {
-                               obj.one->clear_flag( obj_t::dirty );
-                       }
#endif
                }
+#ifdef MULTI_THREAD
+               obj.one->display_after(xpos, ypos, clip_num );
+#else
+               obj.one->display_after( xpos, ypos, is_global );
+               if(  is_global  ) {
+                       obj.one->clear_flag( obj_t::dirty );
+               }
+#endif
                return;
        }


prissi

When the start offset is >0 or the capacity==0 there is nothing to draw. So putting it out of the bracket is clearly wrong. There could be a logic error elsewhere. Which tooltips does not work?

Philip

Quote from: prissi on August 21, 2014, 08:53:04 PM
When the start offset is >0 or the capacity==0 there is nothing to draw. So putting it out of the bracket is clearly wrong. There could be a logic error elsewhere. Which tooltips does not work?

I don't think that's clear at all, it's precisely what the other functions do: don't draw way objects or vehicles below the start offset, but do draw tooltips on them.

I'm pretty sure the behaviour this patch restores (which is identical to the behaviour of display_obj_bg, and also to the behaviour of display_obj_quick_and_dirty when capacity != 1) is intentional, and consistent which the way the function is actually called.

If you think that behaviour is wrong, here's a patch that removes it--but then I see no way tooltips on ways (or vehicles!) would ever work. (I don't know whether there are tooltips on ways in standard Simutrans, but the other patch we've discussed would add them).


diff --git a/dataobj/objlist.cc b/dataobj/objlist.cc
index 7d3bd5e..4e71daf 100644
--- a/dataobj/objlist.cc
+++ b/dataobj/objlist.cc
@@ -1153,5 +1153,5 @@ void objlist_t::display_obj_quick_and_dirty( const sint16 xpos, const sint16 ypo
}
// foreground (needs to be done backwards!
- for(  size_t n = top;  n-- != 0;    ) {
+ for(  size_t n = top;  n-- != start_offset;    ) {
#ifdef MULTI_THREAD
obj.some[n]->display_after( xpos, ypos, clip_num );
@@ -1329,16 +1329,13 @@ void objlist_t::display_obj_fg( const sint16 xpos, const sint16 ypos, const uint
#ifdef MULTI_THREAD
obj.one->display( xpos, ypos, clip_num );
+ obj.one->display_after( xpos, ypos, clip_num );
#else
obj.one->display( xpos, ypos );
+ obj.one->display_after( xpos, ypos, is_global );
+ if(  is_global  ) {
+   obj.one->clear_flag(obj_t::dirty);
+ }
#endif
}
-#ifdef MULTI_THREAD
- obj.one->display_after( xpos, ypos, clip_num );
-#else
- obj.one->display_after( xpos, ypos, is_global );
- if(  is_global  ) {
- obj.one->clear_flag(obj_t::dirty);
- }
-#endif
return;
}
@@ -1352,5 +1349,5 @@ void objlist_t::display_obj_fg( const sint16 xpos, const sint16 ypos, const uint
}
// foreground (needs to be done backwards!)
- for(  size_t n = top;  n-- != 0;    ) {
+ for(  size_t n = top;  n-- != start_offset;    ) {
#ifdef MULTI_THREAD
obj.some[n]->display_after( xpos, ypos, clip_num );




I think without the first patch, tooltips on vehicles on tiles with capacity == 1 (which is a really rare case) are broken.

prissi

capacity==1 happens for ships on water, and tooltips there work.

But I have to dig through this code again, it has been some time since the last change.

EDIT: Apologies, I see I am wrong and you are right. WIll be incorporated, that you.