Skip to content
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

Create new GameImports/GameExports instance every time new map is created #69

Merged
merged 5 commits into from
Aug 5, 2021

Conversation

demoth
Copy link
Owner

@demoth demoth commented Jul 26, 2021

Do not reuse the same instance of GameImports/GameExports between maps

Also fixed:

  • Config string type description
  • fixed serverMain.clients usage
  • Add network logging

@Override
public void fromPrevious(GameExports oldGame) {
GameExportsImpl oldGameImpl = (GameExportsImpl) oldGame;
// assert both client arrays are of the same size
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not clear.
Feels like there should be an assert here and then only one length should be checked in the for condition.

}

public String getType(int index) {
if (index == CS_NAME) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a way to generate this switch

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in it's current form

return "CS_MAXCLIENTS";
} else if (index == CS_MAPCHECKSUM) {
return "CS_MAPCHECKSUM";
} else if (index < CS_SOUNDS) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙀

@@ -44,12 +44,12 @@ public SV_GAME(GameImportsImpl gameImports) {
*
* Sends the contents of the mutlicast buffer to a single client.
*/
public void PF_Unicast(int p, boolean reliable, NetworkMessage msg) {
public void PF_Unicast(int index, boolean reliable, NetworkMessage msg) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminds me of the Hlopin naming convention

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PF...

if (cl.state == ClientStates.CS_FREE) {
index = i;
break;
}
i++;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, looks ugly - i guess it's the only place where index is required - everywhere else i managed to use for each. Anyway - its' the subject to change in nearest future

final client_t client = clients.get(i);
client.edict = ent;
edict_t ent = gameImports.gameExports.getEdict(i + 1);
client.edict = ent; // fixme: why? isn't it already set?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

if (cl.edict != null) { // free client slots will have null values
cl.edict.inuse = savedInuse[i];
}
i++;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question about ListIterator

@demoth demoth merged commit f5f4101 into main Aug 5, 2021
@demoth demoth deleted the map-new-instance branch August 5, 2021 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants