@@ -3067,64 +3067,37 @@ void Server::notifyPlayers(const std::wstring &msg)
3067
3067
SendChatMessage (PEER_ID_INEXISTENT,msg);
3068
3068
}
3069
3069
3070
- void Server::spawnParticle (const char * playername, v3f pos,
3070
+ void Server::spawnParticle (const std::string & playername, v3f pos,
3071
3071
v3f velocity, v3f acceleration,
3072
3072
float expirationtime, float size, bool
3073
3073
collisiondetection, bool vertical, const std::string &texture)
3074
3074
{
3075
- Player *player = m_env->getPlayer (playername);
3076
- if (!player)
3077
- return ;
3078
- SendSpawnParticle (player->peer_id , pos, velocity, acceleration,
3079
- expirationtime, size, collisiondetection, vertical, texture);
3080
- }
3075
+ u16 peer_id = PEER_ID_INEXISTENT;
3076
+ if (playername != " " ) {
3077
+ Player* player = m_env->getPlayer (playername.c_str ());
3078
+ if (!player)
3079
+ return ;
3080
+ peer_id = player->peer_id ;
3081
+ }
3081
3082
3082
- void Server::spawnParticleAll (v3f pos, v3f velocity, v3f acceleration,
3083
- float expirationtime, float size,
3084
- bool collisiondetection, bool vertical, const std::string &texture)
3085
- {
3086
- SendSpawnParticle (PEER_ID_INEXISTENT,pos, velocity, acceleration,
3083
+ SendSpawnParticle (peer_id, pos, velocity, acceleration,
3087
3084
expirationtime, size, collisiondetection, vertical, texture);
3088
3085
}
3089
3086
3090
- u32 Server::addParticleSpawner (const char *playername, u16 amount, float spawntime,
3087
+ u32 Server::addParticleSpawner (u16 amount, float spawntime,
3091
3088
v3f minpos, v3f maxpos, v3f minvel, v3f maxvel, v3f minacc, v3f maxacc,
3092
3089
float minexptime, float maxexptime, float minsize, float maxsize,
3093
- bool collisiondetection, bool vertical, const std::string &texture)
3090
+ bool collisiondetection, bool vertical, const std::string &texture,
3091
+ const std::string &playername)
3094
3092
{
3095
- Player *player = m_env->getPlayer (playername);
3096
- if (!player)
3097
- return -1 ;
3098
-
3099
- u32 id = 0 ;
3100
- for (;;) // look for unused particlespawner id
3101
- {
3102
- id++;
3103
- if (std::find (m_particlespawner_ids.begin (),
3104
- m_particlespawner_ids.end (), id)
3105
- == m_particlespawner_ids.end ())
3106
- {
3107
- m_particlespawner_ids.push_back (id);
3108
- break ;
3109
- }
3093
+ u16 peer_id = PEER_ID_INEXISTENT;
3094
+ if (playername != " " ) {
3095
+ Player* player = m_env->getPlayer (playername.c_str ());
3096
+ if (!player)
3097
+ return -1 ;
3098
+ peer_id = player->peer_id ;
3110
3099
}
3111
3100
3112
- SendAddParticleSpawner (player->peer_id , amount, spawntime,
3113
- minpos, maxpos, minvel, maxvel, minacc, maxacc,
3114
- minexptime, maxexptime, minsize, maxsize,
3115
- collisiondetection, vertical, texture, id);
3116
-
3117
- return id;
3118
- }
3119
-
3120
- u32 Server::addParticleSpawnerAll (u16 amount, float spawntime,
3121
- v3f minpos, v3f maxpos,
3122
- v3f minvel, v3f maxvel,
3123
- v3f minacc, v3f maxacc,
3124
- float minexptime, float maxexptime,
3125
- float minsize, float maxsize,
3126
- bool collisiondetection, bool vertical, const std::string &texture)
3127
- {
3128
3101
u32 id = 0 ;
3129
3102
for (;;) // look for unused particlespawner id
3130
3103
{
@@ -3138,34 +3111,29 @@ u32 Server::addParticleSpawnerAll(u16 amount, float spawntime,
3138
3111
}
3139
3112
}
3140
3113
3141
- SendAddParticleSpawner (PEER_ID_INEXISTENT , amount, spawntime,
3114
+ SendAddParticleSpawner (peer_id , amount, spawntime,
3142
3115
minpos, maxpos, minvel, maxvel, minacc, maxacc,
3143
3116
minexptime, maxexptime, minsize, maxsize,
3144
3117
collisiondetection, vertical, texture, id);
3145
3118
3146
3119
return id;
3147
3120
}
3148
3121
3149
- void Server::deleteParticleSpawner (const char * playername, u32 id)
3122
+ void Server::deleteParticleSpawner (const std::string & playername, u32 id)
3150
3123
{
3151
- Player *player = m_env->getPlayer (playername);
3152
- if (!player)
3153
- return ;
3154
-
3155
- m_particlespawner_ids.erase (
3156
- std::remove (m_particlespawner_ids.begin (),
3157
- m_particlespawner_ids.end (), id),
3158
- m_particlespawner_ids.end ());
3159
- SendDeleteParticleSpawner (player->peer_id , id);
3160
- }
3124
+ u16 peer_id = PEER_ID_INEXISTENT;
3125
+ if (playername != " " ) {
3126
+ Player* player = m_env->getPlayer (playername.c_str ());
3127
+ if (!player)
3128
+ return ;
3129
+ peer_id = player->peer_id ;
3130
+ }
3161
3131
3162
- void Server::deleteParticleSpawnerAll (u32 id)
3163
- {
3164
3132
m_particlespawner_ids.erase (
3165
3133
std::remove (m_particlespawner_ids.begin (),
3166
3134
m_particlespawner_ids.end (), id),
3167
3135
m_particlespawner_ids.end ());
3168
- SendDeleteParticleSpawner (PEER_ID_INEXISTENT , id);
3136
+ SendDeleteParticleSpawner (peer_id , id);
3169
3137
}
3170
3138
3171
3139
Inventory* Server::createDetachedInventory (const std::string &name)
0 commit comments