-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
+ Config string type description
@Override | ||
public void fromPrevious(GameExports oldGame) { | ||
GameExportsImpl oldGameImpl = (GameExportsImpl) oldGame; | ||
// assert both client arrays are of the same size |
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.
This is not clear.
Feels like there should be an assert here and then only one length should be checked in the for
condition.
qcommon/src/main/java/jake2/qcommon/network/messages/NetworkPacket.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
public String getType(int index) { | ||
if (index == CS_NAME) { |
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.
I wonder if there is a way to generate this switch
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.
not in it's current form
return "CS_MAXCLIENTS"; | ||
} else if (index == CS_MAPCHECKSUM) { | ||
return "CS_MAPCHECKSUM"; | ||
} else if (index < CS_SOUNDS) { |
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.
🙀
@@ -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) { |
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.
Reminds me of the Hlopin naming convention
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.
PF...
if (cl.state == ClientStates.CS_FREE) { | ||
index = i; | ||
break; | ||
} | ||
i++; |
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.
I wonder if ListIterator
is more idiomatic
https://stackoverflow.com/questions/7167253/is-there-a-java-equivalent-of-pythons-enumerate-function
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.
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? |
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 (cl.edict != null) { // free client slots will have null values | ||
cl.edict.inuse = savedInuse[i]; | ||
} | ||
i++; |
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.
Same question about ListIterator
…cket.java Co-authored-by: samoylovfp <samoylovfp@gmail.com>
Do not reuse the same instance of GameImports/GameExports between maps
Also fixed: