New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cast system #2007
Cast system #2007
Conversation
Hopefully this cast system will be acceptable.
Awesome!!!! @testing.. |
if someone enter on cast this got name, spectator 1, and other ppl enter got name spectator2. But if spectator 1 leave and enter again, he got name spectator 2 too, resulting in 2 ppls with name spectator2. If someone enter with specator 1 name... and get ban or something and other other ppl, then he enter like spectator 1 and CRASH. solution: maybe put this for no reset, for spectator 1, and still counting spectator 1,2,3,4,5,... at cast restarts. suggestion: |
} | ||
|
||
if(command == "commands") { | ||
player->sendChannelMessage("", "Available commands:", TALKTYPE_CHANNEL_O, CHANNEL_CAST, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data race on the player object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing this out, do you have any tip on how i SHOULD handle these things to not data race? Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule is that most (if not all) parse* functions are run in the networking thread. You would either need to add some kind of synchronization mechanism to Player (e.g. mutex) or run a function in the dispatcher.
if(recvbyte == 0x64) { | ||
sendCancelWalk(); | ||
} | ||
sendMoveCreature(player, player->getPosition(), player->getTile()->getStackposOfCreature(spectator, player->getCreature()), player->getPosition(), player->getTile()->getStackposOfCreature(spectator, player->getCreature()), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data race on the player object.
@@ -105,7 +105,7 @@ struct Skill { | |||
|
|||
typedef std::map<uint32_t, uint32_t> MuteCountMap; | |||
|
|||
static constexpr int32_t PLAYER_MAX_SPEED = 1500; | |||
static constexpr int32_t PLAYER_MAX_SPEED = 5000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing this, forgot to revert from my local test.
@@ -1260,6 +1300,7 @@ class Player final : public Creature, public Cylinder | |||
int32_t offlineTrainingSkill = -1; | |||
int32_t offlineTrainingTime = 0; | |||
int32_t idleTime = 0; | |||
uint32_t spectatorCount = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of this variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable removed. Thank you for pointing this out.
@@ -1182,6 +1218,9 @@ class Player final : public Creature, public Cylinder | |||
std::map<uint32_t, int32_t> storageMap; | |||
|
|||
std::vector<OutfitEntry> outfits; | |||
std::vector<ProtocolSpectator*> spectators; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storing raw pointers to objects managed by shared_ptr is a bad idea IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified to store a shared_ptr, thanks.
@@ -865,6 +1003,20 @@ void ProtocolGame::parseSay(NetworkMessage& msg) | |||
return; | |||
} | |||
|
|||
if(channelId == CHANNEL_CAST && player->isLiveCasting()) { | |||
InstantSpell* instantSpell = g_spells->getInstantSpell(text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data race on g_spells.
@@ -865,6 +1003,20 @@ void ProtocolGame::parseSay(NetworkMessage& msg) | |||
return; | |||
} | |||
|
|||
if(channelId == CHANNEL_CAST && player->isLiveCasting()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data race on the player object.
player->sendChannelMessage("", ss.str(), TALKTYPE_CHANNEL_O, CHANNEL_CAST); | ||
} | ||
spectator->client.reset(); | ||
spectator = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak of spectator?
What is the differences related to @djarek cast system? |
any progress? bugs has been fixeds? |
login12 |
Database* db = Database::getInstance(); | ||
|
||
std::ostringstream query; | ||
query << "UPDATE `players_online` SET `cast_password` = '" << db->escapeString(password) << "' WHERE `player_id` = '" << getGUID() <<"';"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not wrong, you should change:
cast_password
= '" << db->escapeString(password) << "'
to:
cast_password
= " << db->escapeString(password) << "
Getting SQL errors when I use a password.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes in !cast (password) get error in console in !cast and connect to spect get debug and crash server this code its crappy ...
CREATE TABLE IF NOT EXISTS players_online
(
player_id
int(11) NOT NULL,
cast_password
varchar(30) DEFAULT NULL,
cast_spectators
smallint(5) NOT NULL DEFAULT '0',
PRIMARY KEY (player_id
)
) ENGINE=MEMORY;
missing " , "
I found a problem, if u enter in cast with 2+ ppl and u have monsters/creatures in screen he debug. (i think is anything type move creature idk). |
Eternal-Scripts on tfs 1,2 or 1,3? on my 1.2 this system crash after spec connect to caster |
Working good with normal client but cause crash if I login as spectator with OTClient. Anyone can confirm this? |
I don't know if you are still working on this, but: TFS Crash. |
Hopefully this cast system will be acceptable.