evemuproject / evemu_server

MAIN SERVER DEVELOPMENT
http://www.evemu.org
148 stars 103 forks source link

compile error 145-147 ConfigDB.cpp #155

Closed klyxmaster closed 6 years ago

klyxmaster commented 6 years ago

the following looks correct but the compiler is throwing an error: any ideas I can try?

 for (auto cur : entityIDs) {

        if (IsStaticMapItem(cur) or (cur == 0))
            staticItem.push_back(cur);
        else
            dynamicItem.push_back(cur);
    }

Severity Code Description Project File Line Suppression State Error (active) E0018 expected a ')' eve-server d:_crusable_evemu_src\src\eve-server\config\ConfigDB.cpp 145 Error C2146 syntax error: missing ')' before identifier 'or' eve-server D:_crusable_evemu_src\src\eve-server\config\ConfigDB.cpp 145 Error C3861 'or': identifier not found eve-server D:_crusable_evemu_src\src\eve-server\config\ConfigDB.cpp 145 Error C2059 syntax error: ')' eve-server D:_crusable_evemu_src\src\eve-server\config\ConfigDB.cpp 145 Error C2146 syntax error: missing ';' before identifier 'staticItem' eve-server D:_crusable_evemu_src\src\eve-server\config\ConfigDB.cpp 146 Error C2181 illegal else without matching if eve-server D:_crusable_evemu_src\src\eve-server\config\ConfigDB.cpp 147

Stranho commented 6 years ago

Is not "or" it is "||", so it'll be like this:

if (IsStaticMapItem(cur) || (cur == 0))

I recommend to change the check for null first, like this: if ((cur == 0) || IsStaticMapItem(cur))

remember, you are adding a null item in the static item, maybe you want it be diffrent from null (0)

if ((cur != 0) && IsStaticMapItem(cur)) this check for 'cur' being not null and a static map item, so you're not adding a null item in the list.

hope this helps.

zhyrohaad commented 6 years ago

"or" is keyword for "||" on newer gcc and windows compilers for g++0x11 and later. your compiler doesnt like conditional keywords (Error C3861 'or': identifier not found) , so this will need to be changed to "||" as stranho suggested. there will be other conditional keywords you will have to search for and replace also. stranho is right in suggesting checking for null first, this particular code is being passed a list of itemIDs to search the db for. in this case, it dont matter which one you test first, either static item or "0", as it will insert the value into the 'staticItem" vector if either of those are true. however, i have found a value of "0" will throw an error if the db search is allowed, and the client doesnt like it, either.

i have updated this check to throw an error when "0" is passed (which happens on rare occasions), but have not updated this codebase.

this entire conditional block should be as follows:

for (auto cur : entityIDs) { if (cur == 0) { sLog.Error("GetMultiLocationsEx", "Client sent 0"); continue; } if (IsStaticMapItem(cur) or (cur == 0)) staticItem.push_back(cur); else dynamicItem.push_back(cur); }

when i get time i'll look over the code and update.

let us know if you have any other problems.