AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   CS2 Metamod Plugin std::stringstream (https://forums.alliedmods.net/showthread.php?t=345344)

Toxa 01-06-2024 07:42

CS2 Metamod Plugin std::stringstream
 
Hi there!

Can someone please tell me why is stringstream not working with int's inside the metamod plugin?
E.g.:
Code:

//this works
std::stringstream ss;
ss << "123";
//ss.bad() == false here

Code:

//this not works
std::stringstream ss;
ss << 123;
//ss.bad() == true here

Seems like all streams (std::cout, std::clog, std::cerr) not working with any numbers (int/double). If cout, clog, cerr is objects and engine or metamod can replace e.g. rdbuf for them so why even stringstream not working?

Bacardi 01-06-2024 08:00

Re: CS2 Metamod Plugin std::stringstream
 
There are many c++ examples, what use also string and stringstream.

Also, try this:
Create variable int with value.
Add that in your stringstream ss <<

Toxa 01-06-2024 08:19

Re: CS2 Metamod Plugin std::stringstream
 
Quote:

Originally Posted by Bacardi (Post 2815645)
There are many c++ examples, what use also string and stringstream.

Also, try this:
Create variable int with value.
Add that in your stringstream ss <<

Not works as well.
Code:

std::stringstream ss;
int a = 777;
ss << a;
//ss.bad() == true here, ss.str() is empty

Im using s1_stub_mm example from latest mm sources and latest hl2sdk-cs2. This code was launched inside the Load function.

Bacardi 01-06-2024 09:15

Re: CS2 Metamod Plugin std::stringstream
 
I would start looking <string> and format.
https://en.cppreference.com/w/cpp/utility/format/format

Forget stringstream :S


Edit
Sprintf https://forums.alliedmods.net/showpo...65&postcount=5

Toxa 01-06-2024 09:42

Re: CS2 Metamod Plugin std::stringstream
 
Quote:

Originally Posted by Bacardi (Post 2815652)
I would start looking <string> and format.
https://en.cppreference.com/w/cpp/utility/format/format

Forget stringstream :S


Edit
Sprintf https://forums.alliedmods.net/showpo...65&postcount=5

Thanks, I know about the formatting functions. But stringstream is used inside some libraries that I want to use. And they break when loading from mm.

I will try to investigate more

Bacardi 01-06-2024 14:34

Re: CS2 Metamod Plugin std::stringstream
 
What if you do:

ss << 123 << " ";

Toxa 01-07-2024 01:56

Re: CS2 Metamod Plugin std::stringstream
 
Quote:

Originally Posted by Bacardi (Post 2815678)
What if you do:

ss << 123 << " ";

Same. After ss << 123 stream state is bad.

Bacardi 01-07-2024 05:28

Re: CS2 Metamod Plugin std::stringstream
 
If this has something to do iostream badbit...

What if you use:
ss.clear();

...after you declare stringstream variable?

But something is off, can't say what.
Also, what require stringstream ?

If above thing not help.
Try use string and format.
Then finally, add that string into stringstream


All times are GMT -4. The time now is 07:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.