Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15731

C++: Text was not handled properly, first \r\n was not parsed

$
0
0

I'm porting a open source game client from PC to Android, however when dealing with NPC chat, some lines are not parsed correctly:

Original text from server:

formatted_text_ = "Now...ask me any questions you may have on traveling!!\r\n#L0##bHow do I move?#l\r\n#L1#How do I take down the monsters?#l\r\n#L2#How can I pick up an item?#l\r\n#L3#What happens when I die?#l\r\n#L4#When can I choose a job?#l\r\n#L5#Tell me more about this island!#l\r\n#L6#What should I do to become a Warrior?#l\r\n#L7#What should I do to become a Bowman?#l\r\n#L8#What should I do to become a Magician?#l\r\n#L9#What should I do to become a Thief?#l\r\n#L10#How do I raise the character stats? (S)#l\r\n#L11#How do I check the items that I just picked up?#l\r\n#L12#How do I put on an item?#l\r\n#L13#How do I check out the items that I'm wearing?#l\r\n#L14#What are skills? (K)#l\r\n#L15#How do I get to Victoria Island?#l\r\n#L16#What are mesos?#l#k"

Second line "How do I move" is not started as a new line, other lines ended with \r\n are parsed normally by following a new line.

How \r and \n are handled:

            switch (text[first]) {                case '\\':                    if (first + 1 < last) {                        switch (text[first + 1]) {                            case 'n':                                linebreak = true;                                break;                            case 'r':                                linebreak = ax_ > 0;                                break;                        }                        skip++;                    }                    skip++;                    break;

enter image description hereHow formatted_text_ was handled:

https://github.com/speedyHKjournalist/OpenMapleClient/blob/521af535bb65fb231296d02f1d19a6f38e77673d/app/src/main/cpp/src/IO/UITypes/UINpcTalk.cpp#L141

https://github.com/speedyHKjournalist/OpenMapleClient/blob/73ddd15f443cc0ab9f796ce362a67d73e5e453ad/app/src/main/cpp/src/Graphics/GraphicsGL.cpp#L617

https://github.com/speedyHKjournalist/OpenMapleClient/blob/73ddd15f443cc0ab9f796ce362a67d73e5e453ad/app/src/main/cpp/src/Graphics/GraphicsGL.cpp#L657


Viewing all articles
Browse latest Browse all 15731

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>