Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored Instances to utilize C++ features #3163

Merged
merged 67 commits into from
Apr 8, 2020
Merged

Conversation

aleos89
Copy link
Contributor

@aleos89 aleos89 commented May 27, 2018

TODO:

  • Convert instance_wait to dynamic array.

aleos89 and others added 6 commits May 27, 2018 11:28
* Fixes #3087 and fixes #3095.
* Converted database file to YAML.
* Converted static array to unordered_map which frees up 14400+ bytes of pre-allocated memory that may never be fully used.
* Got rid of all DBMap/ERS features.
* Resolved a compile error.
* Adjusted Windows build to properly move the import file over.
* Removed some left overs.
* Removed references.
* Adjusted the instance name search to start to an iterator.
* Renamed Maps field to AdditionalMaps.
Thanks to @Lemongrass3110 and @secret!
* Final compile error.
* Added database file adjustments.
* Fixed a few instances of string to c_str conversions.
@aleos89 aleos89 added the status:code-review Pull Request that requires reviewing from other developers before being pushed to master label May 29, 2018
aleos89 and others added 5 commits June 13, 2018 16:37
* Added new instances.
* Allows for quick and dynamic modification.
* Reduces memory usage of statically allocated array.
# Conflicts:
#	src/map/instance.cpp
#	src/map/instance.hpp
* Instance names should also be unique as they have their own lookup.
Thanks to @Atemo!
* Corrected a compile error.
* Cleaned up instance enter location parsing.
@ghost
Copy link

ghost commented Jul 1, 2018

Does this include the fix for #3150 ?

@aleos89
Copy link
Contributor Author

aleos89 commented Jul 2, 2018

No, but we have some code in place for it’s implementation after this gets pushed to master. Wanted to keep a feature addition separate from a refactor.

@mjonrest
Copy link

mjonrest commented Jul 9, 2018

instance.cpp: In function ‘void instance_addnpc(std::shared_ptr<s_instance_data>)’:
instance.cpp:368:28: error: request for member ‘size’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
for(i = 0; i < idata->map.size(); i++)
^~~~
instance.cpp:369:59: error: request for member ‘src_m’ in ‘
(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map’ (maybe you meant to use ‘->’ ?)
map_foreachinallarea(instance_addnpc_sub, idata->map[i].src_m, 0, 0, map[idata->map[i].src_m].xs, map[idata->map[i].src_m].ys, BL_NPC, idata->map[i].m);
^~~~~
instance.cpp:369:90: error: request for member ‘src_m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
a(instance_addnpc_sub, idata->map[i].src_m, 0, 0, map[idata->map[i].src_m].xs, map[idata->map[i].src_m].ys, BL_NPC, idata->map[i].m);
^~~~~
instance.cpp:369:119: error: request for member ‘src_m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
map[i].src_m, 0, 0, map[idata->map[i].src_m].xs, map[idata->map[i].src_m].ys, BL_NPC, idata->map[i].m);
^~~~~
instance.cpp:369:152: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)) ’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
idata->map[i].src_m].xs, map[idata->map[i].src_m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp:372:28: error: request for member ‘size’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
for(i = 0; i < idata->map.size(); i++)
^~~~
instance.cpp:373:56: error: request for member ‘m’ in ‘
(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map’ (maybe you meant to use ‘->’ ?)
map_foreachinallarea(instance_npcinit, idata->map[i].m, 0, 0, map[idata->map[i].m].xs, map[idata->map[i].m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp:373:83: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
nallarea(instance_npcinit, idata->map[i].m, 0, 0, map[idata->map[i].m].xs, map[idata->map[i].m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp:373:108: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)) ’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
, idata->map[i].m, 0, 0, map[idata->map[i].m].xs, map[idata->map[i].m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp:373:137: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)) ’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
0, map[idata->map[i].m].xs, map[idata->map[i].m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp: In function ‘int instance_addmap(uint16)’:
instance.cpp:515:13: error: request for member ‘push_back’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
idata->map.push_back(entry);
^~~~~~~~~
instance.cpp:525:15: error: request for member ‘push_back’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>
)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
idata->map.push_back(entry);
^~~~~~~~~
instance.cpp:555:20: error: request for member ‘size’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
return idata->map.size();
^~~~
instance.cpp: In function ‘int16 instance_mapid(int16, uint16)’:
instance.cpp:583:36: error: request for member ‘size’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>
)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
for (uint16 i = 0; i < idata->map.size(); i++) {
^~~~
instance.cpp:584:21: error: request for member ‘src_m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
if (idata->map[i].src_m == m) {
^~~~~
instance.cpp: In function ‘bool instance_destroy(uint16)’:
instance.cpp:670:29: error: request for member ‘size’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
for(i = 0; i < idata->map.size(); i++)
^~~~
instance.cpp:671:60: error: request for member ‘m’ in ‘
(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map’ (maybe you meant to use ‘->’ ?)
map_foreachinallarea(instance_npcdestroy, idata->map[i].m, 0, 0, map[idata->map[i].m].xs, map[idata->map[i].m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp:671:87: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
larea(instance_npcdestroy, idata->map[i].m, 0, 0, map[idata->map[i].m].xs, map[idata->map[i].m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp:671:112: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)) ’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
, idata->map[i].m, 0, 0, map[idata->map[i].m].xs, map[idata->map[i].m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp:671:141: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)) ’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
0, map[idata->map[i].m].xs, map[idata->map[i].m].ys, BL_NPC, idata->map[i].m);
^
instance.cpp:672:29: error: request for member ‘size’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
for(i = 0; i < idata->map.size(); i++)
^~~~
instance.cpp:673:37: error: request for member ‘m’ in ‘
(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map’ (maybe you meant to use ‘->’ ?)
map_delinstancemap(idata->map[i].m);
^
instance.cpp:674:14: error: request for member ‘clear’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
idata->map.clear();
^~~~~
instance.cpp: In function ‘bool instance_delusers(uint16)’:
instance.cpp:893:32: error: request for member ‘size’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>
)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
for(int i = 0; i < idata->map.size() && idata->map[i].m; i++)
^~~~
instance.cpp:893:56: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
for(int i = 0; i < idata->map.size() && idata->map[i].m; i++)
^
instance.cpp:894:34: error: request for member ‘m’ in ‘(((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map + ((sizetype)(((long unsigned int)i) * 8)))’, which is of pointer type ‘s_instance_map*’ (maybe you meant to use ‘->’ ?)
users += max(map[idata->map[i].m].users,0);
^
instance.cpp: In function ‘void do_reload_instance()’:
instance.cpp:1147:19: error: request for member ‘size’ in ‘((std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>*)(& idata))->std::__shared_ptr_access<s_instance_data, (__gnu_cxx::_Lock_policy)2, false, false>::operator->()->s_instance_data::map’, which is of non-class type ‘s_instance_map**’
if (!idata->map.size())

i found this error.. can someone help me with this

@aleos89
Copy link
Contributor Author

aleos89 commented Jul 10, 2018

Looks like you have a bad merge. I cannot reproduce this.

@mjonrest
Copy link

@aleos89 i have follow all steps and commits and this happen.. i use latest master from rathena..

@aleos89
Copy link
Contributor Author

aleos89 commented Jul 12, 2018

I'd check your s_instance_data struct and make sure your define of map is a vector and not the previous ERS format.

@mjonrest
Copy link

@Do you need my src folder?? i can share it to you

* Follow up to 0476686.
Thanks to @ecdarreola!
@lgtm-com
Copy link

lgtm-com bot commented Mar 25, 2020

This pull request fixes 2 alerts when merging cfaefa2 into 24ecebc - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same
  • 1 for Comparison of narrow type with wide type in loop condition

@ecdarreola
Copy link

Timer is now showing properly. Image below.

Test 1:
image

Test 2:
image

Thank you. Everything is working great!

@CairoLee
Copy link
Contributor

@CairoLee is there an issue I'm missing or you're bumping so it gets merged to master?

Sorry for making you misunderstand, Sir. I did not encounter any issues. I just so looking forward to this pull request. but i seem there has been no activity in the last month, so I "remind" you to pay attention to it. ;D

@lgtm-com
Copy link

lgtm-com bot commented Mar 30, 2020

This pull request fixes 2 alerts when merging df651cb into 2f326bf - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same
  • 1 for Comparison of narrow type with wide type in loop condition

* Converts the Additional Maps format to support importing.
* Fixes an invalid map name check.
@lgtm-com
Copy link

lgtm-com bot commented Mar 31, 2020

This pull request fixes 2 alerts when merging e4f1d72 into 2f326bf - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same
  • 1 for Comparison of narrow type with wide type in loop condition

@lgtm-com
Copy link

lgtm-com bot commented Apr 1, 2020

This pull request fixes 2 alerts when merging a9302e3 into ad820c1 - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same
  • 1 for Comparison of narrow type with wide type in loop condition

* Adjusts some checks for the change from unsigned short to int of instance_id.
@lgtm-com
Copy link

lgtm-com bot commented Apr 7, 2020

This pull request fixes 2 alerts when merging 4e21219 into 3424928 - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same
  • 1 for Comparison of narrow type with wide type in loop condition

* Adds a map name length check when creating unique IDs to not exceed 999.
Thanks to @Atemo!
@lgtm-com
Copy link

lgtm-com bot commented Apr 7, 2020

This pull request fixes 2 alerts when merging 4aec65c into 3424928 - view on LGTM.com

fixed alerts:

  • 1 for Comparison result is always the same
  • 1 for Comparison of narrow type with wide type in loop condition

@aleos89 aleos89 merged commit 06c159c into master Apr 8, 2020
@aleos89 aleos89 deleted the refactor/instances branch April 8, 2020 16:52
@aleos89 aleos89 removed the status:code-review Pull Request that requires reviewing from other developers before being pushed to master label Apr 8, 2020
@Chywoner
Copy link

How to resolve this error?

image

@Lemongrass3110
Copy link
Member

How to resolve this error?

image

Update correctly. You are either missing the include or the using directive.

@SeravySensei
Copy link
Contributor

How to resolve this error?
image

Update correctly. You are either missing the include or the using directive.

Having the same problem. If I right click the "util" and select "go to definition", it does find the declaration "namespace util" in utilities.hpp which seems to be listed as an include but I can't compile it anyway.
... changing to "rathena::util::.." fixed the errors. I hope that was the correct solution.

@aleos89
Copy link
Contributor Author

aleos89 commented May 6, 2020

You're forgetting the using namespace rathena; definition at the to near the includes.

@admkakaroto
Copy link
Contributor

@aleos89 #3150
Will this old report still be worked on? in it you said it would be in this PR, but ended up being forgotten.

@Atemo
Copy link
Contributor

Atemo commented Jun 8, 2020

Maybe Aleos meant #3753 ?

@aleos89
Copy link
Contributor Author

aleos89 commented Jun 8, 2020

It's not forgotten about. I've just been working on other tasks.

@admkakaroto
Copy link
Contributor

Oh, fine then, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.