Linux compile error: rev 1184
Moderator: Community Managers
- John Adams
- Retired
- Posts: 4581
- Joined: Wed Aug 28, 2013 9:40 am
- Location: Phoenix, AZ.
- Contact:
Linux compile error: rev 1184
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.
Anyone?
Note to Xinux:
Not sure what's going on here while looking this over:
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.
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
Note to Xinux:
Not sure what's going on here while looking this over:
Code: Select all
remove(chan_name.begin(), chan_name.end(), '"')
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
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
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
- John Adams
- Retired
- Posts: 4581
- Joined: Wed Aug 28, 2013 9:40 am
- Location: Phoenix, AZ.
- Contact:
Re: Linux compile error: rev 1184
Oh Scatman, how I miss you.
Unfortunately, that didn't work hehe. Stupid Linux.
Unfortunately, that didn't work hehe. Stupid Linux.
Re: Linux compile error: rev 1184
Whoops, I read that wrong. That might not work. But you could do this:
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!
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';
....
}
Re: Linux compile error: rev 1184
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
you could also pass in a variable amount of characters to remove! hang tight..
Re: Linux compile error: rev 1184
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");
- Blackstorm
- Retired
- Posts: 354
- Joined: Thu Sep 04, 2014 11:11 am
- Location: Paris, FRANCE
- Contact:
Re: Linux compile error: rev 1184
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...
If i have time i will investigate...