{"id":121,"date":"2014-06-01T18:33:09","date_gmt":"2014-06-01T18:33:09","guid":{"rendered":"https:\/\/blogs.scummvm.org\/josejx\/?p=121"},"modified":"2022-05-21T18:33:58","modified_gmt":"2022-05-21T18:33:58","slug":"sectors-and-setups-again","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/josejx\/2014\/06\/01\/sectors-and-setups-again\/","title":{"rendered":"Sectors and Setups Again"},"content":{"rendered":"<p><i>Continued from the <a href=\"https:\/\/blogs.scummvm.org\/josejx\/2014\/05\/29\/more-on-sectors\/\" target=\"_blank\" rel=\"noopener\">previous entry <\/a><\/i><\/p>\n<div>In the last post, we examined the sectors and setups in the <i>set<\/i> files for EMI and GRIM and identified the problem spot.<\/p>\n<p>In the ResisdualVM source, these are the places where the substring check of the sector name is used:<\/p>\n<ul>\n<li><i>Actor::setShadowPlane (called from Lua_V1::SetActorShadowPlane)<\/i><\/li>\n<li><i>Lua_V1::IsPointInSector <\/i><\/li>\n<li><i>Lua_V1::IsActorInSector<\/i><\/li>\n<li><i>Lua_V1::GetSectorOppositeEdge<\/i><\/li>\n<\/ul>\n<\/div>\n<div>After a bunch of decompilation and poking through the game with a debugger, I found that for GRIM:<\/div>\n<div>\n<ul>\n<li><i>SetActorShadowPlane<\/i> appears to use an exact string comparison<\/li>\n<li><i>IsPointInSector<\/i> uses a substring check (_strstr)<\/li>\n<li><i>IsActorInSector<\/i> uses a substring check (_strstr)<\/li>\n<li><i>GetSectorOppositeEdge<\/i> appears to use an exact string comparison<\/li>\n<\/ul>\n<\/div>\n<div>The functions <i>SetActorShadowPlane<\/i> and <i>GetSectorOppositeEdge<\/i> both use a byte by byte comparison to check the string equality.<\/div>\n<div><\/div>\n<div>In EMI, in the original retail version:<\/p>\n<ul>\n<li><i>SetActorShadowPlane<\/i> is not present in EMI<\/li>\n<li><i>IsPointInSector<\/i> is not used in the EMI game scripts<\/li>\n<li><i>IsActorInSector <\/i>appears to use an exact string comparison<\/li>\n<li><i>GetSectorOppositeEdge<\/i> appears to use an exact string comparison<\/li>\n<\/ul>\n<p>I was also given the suggestion to replace the call to <i>getSectorByName(String &amp;str, Vector3d &amp;pos)<\/i> and <i>getSectorByName(char *name, Vector3d &amp;pos)<\/i> by using the versions without the <i>Vector3d<\/i> parameter. This ultimately won&#8217;t work because the GRIM implementation will return incorrect sectors due to the substring string compare.<\/p>\n<p>With all of this information, I can finally say that the updated PR should have the correct behavior for both GRIM and EMI. Whew, that was a lot of work for very little code contribution! Hopefully next week is more productive!<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Continued from the previous entry In the last post, we examined the sectors and setups in the set files for EMI and GRIM and identified the problem spot. In the ResisdualVM source, these are the places where the substring check of the sector name is used: Actor::setShadowPlane (called from Lua_V1::SetActorShadowPlane) Lua_V1::IsPointInSector Lua_V1::IsActorInSector Lua_V1::GetSectorOppositeEdge After a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-121","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/comments?post=121"}],"version-history":[{"count":2,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/121\/revisions"}],"predecessor-version":[{"id":123,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/posts\/121\/revisions\/123"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/media?parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/categories?post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/josejx\/wp-json\/wp\/v2\/tags?post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}