Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
19863267
Commit
19863267
authored
14 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
fixed erroneus handling of many players with no peer existing at same time
parent
a35d8dab
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/server.cpp
+31
-4
31 additions, 4 deletions
src/server.cpp
src/server.h
+8
-5
8 additions, 5 deletions
src/server.h
with
39 additions
and
9 deletions
src/server.cpp
+
31
−
4
View file @
19863267
...
...
@@ -1567,9 +1567,18 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
playername
[
playername_size
-
1
]
=
0
;
// Get player
Player
*
player
=
emergePlayer
(
playername
,
""
);
Player
*
player
=
emergePlayer
(
playername
,
""
,
peer_id
);
//Player *player = m_env.getPlayer(peer_id);
// If failed, cancel
if
(
player
==
NULL
)
{
derr_server
<<
DTIME
<<
"Server: peer_id="
<<
peer_id
<<
": failed to emerge player"
<<
std
::
endl
;
return
;
}
/*
// If a client is already connected to the player, cancel
if(player->peer_id != 0)
{
...
...
@@ -1579,9 +1588,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
<<player->peer_id<<")"<<std::endl;
return;
}
// Set client of player
player->peer_id = peer_id;
*/
// Check if player doesn't exist
if
(
player
==
NULL
)
...
...
@@ -3091,7 +3100,8 @@ RemoteClient* Server::getClient(u16 peer_id)
return
n
->
getValue
();
}
Player
*
Server
::
emergePlayer
(
const
char
*
name
,
const
char
*
password
)
Player
*
Server
::
emergePlayer
(
const
char
*
name
,
const
char
*
password
,
u16
peer_id
)
{
/*
Try to get an existing player
...
...
@@ -3099,9 +3109,25 @@ Player *Server::emergePlayer(const char *name, const char *password)
Player
*
player
=
m_env
.
getPlayer
(
name
);
if
(
player
!=
NULL
)
{
// If player is already connected, cancel
if
(
player
->
peer_id
!=
0
)
{
dstream
<<
"emergePlayer(): Player already connected"
<<
std
::
endl
;
return
NULL
;
}
// Got one.
return
player
;
}
/*
If player with the wanted peer_id already exists, cancel.
*/
if
(
m_env
.
getPlayer
(
peer_id
)
!=
NULL
)
{
dstream
<<
"emergePlayer(): Player with wrong name but same"
" peer_id already exists"
<<
std
::
endl
;
return
NULL
;
}
/*
Create a new player
...
...
@@ -3109,7 +3135,8 @@ Player *Server::emergePlayer(const char *name, const char *password)
{
player
=
new
ServerRemotePlayer
();
//player->peer_id = c.peer_id;
player
->
peer_id
=
PEER_ID_INEXISTENT
;
//player->peer_id = PEER_ID_INEXISTENT;
player
->
peer_id
=
peer_id
;
player
->
updateName
(
name
);
/*
...
...
This diff is collapsed.
Click to expand it.
src/server.h
+
8
−
5
View file @
19863267
...
...
@@ -437,11 +437,14 @@ class Server : public con::PeerHandler
// When called, connection mutex should be locked
RemoteClient
*
getClient
(
u16
peer_id
);
// Gets a player from memory or creates one.
// Caller should check isClientConnected() and set it appropriately.
//
// Call with env and con locked.
Player
*
emergePlayer
(
const
char
*
name
,
const
char
*
password
);
/*
Get a player from memory or creates one.
If player is already connected, return NULL
Call with env and con locked.
*/
Player
*
emergePlayer
(
const
char
*
name
,
const
char
*
password
,
u16
peer_id
);
/*
Update water pressure.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment