Page 1 of 1

Linux compile error: rev 1184

Posted: Sun Apr 05, 2015 2:42 pm
by John Adams
It's not liking the mashup of const char and string. Googled around a bit and saw that how to do it is exactly how Xinux did it, but Linux is complaining.

Code: Select all

Net.cpp: In member function ‘void Net::HandleChatJoinRequest(std::shared_ptr<Client>&, std::shared_ptr<WorldCharacter>&, const char*)’:
Net.cpp:1036:69: error: cannot convert ‘std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}’ to ‘const char*’ for argument ‘1’ to ‘int remove(const char*)’
  chan_name.erase(std::remove(chan_name.begin(), chan_name.end(), '"'), chan_name.end());
                                                                     ^
Net.cpp: In member function ‘void Net::HandleClientGuildRenameRank(std::shared_ptr<Client>&, PacketStruct*)’:
Net.cpp:1440:11: warning: unused variable ‘unknown1’ [-Wunused-variable]
  uint32_t unknown1 = packet->GetUInt32("unknown1");
           ^
make: *** [Net.o] Error 1
Anyone?


Note to Xinux:
Not sure what's going on here while looking this over:

Code: Select all

remove(chan_name.begin(), chan_name.end(), '"')
I thought we were removing ' ' space, not double-quotes?

And also, we shouldn't need std:: in front of string, since string and other dependencies are referenced. But that isn't the issue, just standards.

Re: Linux compile error: rev 1184

Posted: Sun Apr 05, 2015 7:15 pm
by Scatman
Most likely need to change
chan_name.erase(std::remove(chan_name.begin(), chan_name.end(), '"'), chan_name.end());
to
chan_name.erase(std::remove(chan_name.begin(), chan_name.end(), "\""), chan_name.end());

Using single quotes in C will make it be an integer (or a char), where using double quotes will definitely make it a string. I didn't test it though so don't quote (HA) me

Re: Linux compile error: rev 1184

Posted: Sun Apr 05, 2015 7:39 pm
by John Adams
Oh Scatman, how I miss you.

Unfortunately, that didn't work hehe. Stupid Linux.

Re: Linux compile error: rev 1184

Posted: Sun Apr 05, 2015 7:51 pm
by Scatman
Whoops, I read that wrong. That might not work. But you could do this:

Code: Select all

void Net::HandleChatJoinRequest(shared_ptr<Client>& client, shared_ptr<WorldCharacter>& character, const char* name) {
    char new_name[128]; //or a dynmaic size with strlen() of `name' + malloc
    int i, j;
    for (i = 0, j = 0; i < strlen(name); i++) {
        if (name[i] != ' ')
            new_name[j++] = name[i];
    }
    new_name[i] = '\0';
    ....
}
You could make that a function. You could also pass in another buffer and a buffer size if you want to make it common function!

Re: Linux compile error: rev 1184

Posted: Sun Apr 05, 2015 8:15 pm
by Scatman

Code: Select all

char * remove_spaces(const char *str) {
    size_t len, i, j;
    char *ret;

    len = strlen(str);

    //we're removing spaces, the new string can only be as long as the orignal
    if ((ret = (char *)malloc(len + 1)) == NULL) {
        //crap out of memory
        return NULL;
    }

    for (i = 0, j = 0; i < len; i++) {
        if (str[i] != ' ')
            ret[j++] = str[i];
    }

    ret[i] = '\0';

    return ret;
}

Re: Linux compile error: rev 1184

Posted: Sun Apr 05, 2015 8:16 pm
by Scatman
you could also pass in a variable amount of characters to remove! hang tight..

Re: Linux compile error: rev 1184

Posted: Mon Apr 06, 2015 10:50 am
by Faux

Code: Select all

Net.cpp: In member function ‘void Net::HandleClientGuildRenameRank(std::shared_ptr<Client>&, PacketStruct*)’:
Net.cpp:1440:11: warning: unused variable ‘unknown1’ [-Wunused-variable]
  uint32_t unknown1 = packet->GetUInt32("unknown1");
I took care of this one. It was leftover from a bit of debugging I was doing, so I removed the line. It was just a warning, but still.

Re: Linux compile error: rev 1184

Posted: Wed May 13, 2015 9:40 am
by Blackstorm
hum odd.. since few release we have a problem with the regionsay chan... apparently it don't recover the "continent" var and the "continent" var player seem to be always empty... but in all case we should have IoD chan for the regionsay.. so why not... why the chan don't load ??

If i have time i will investigate...