(svn r2590) Fix: [network] Fixed NetworkHandleLocalQueue
This commit is contained in:
		
							
								
								
									
										43
									
								
								network.c
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								network.c
									
									
									
									
									
								
							| @@ -1101,37 +1101,38 @@ static void NetworkSend(void) | |||||||
| // Handle the local-command-queue | // Handle the local-command-queue | ||||||
| static void NetworkHandleLocalQueue(void) | static void NetworkHandleLocalQueue(void) | ||||||
| { | { | ||||||
| 	if (_local_command_queue != NULL) { | 	CommandPacket *cp, **cp_prev; | ||||||
| 		CommandPacket *cp; |  | ||||||
| 		CommandPacket *cp_prev; |  | ||||||
|  |  | ||||||
| 		cp = _local_command_queue; | 	cp_prev = &_local_command_queue; | ||||||
| 		cp_prev = NULL; |  | ||||||
|  | 	while ( (cp = *cp_prev) != NULL) { | ||||||
|  |  | ||||||
|  | 		// The queue is always in order, which means | ||||||
|  | 		// that the first element will be executed first. | ||||||
|  | 		if (_frame_counter < cp->frame) | ||||||
|  | 			break; | ||||||
|  |  | ||||||
| 		while (cp != NULL) { |  | ||||||
| 		if (_frame_counter > cp->frame) { | 		if (_frame_counter > cp->frame) { | ||||||
|  | 			// If we reach here, it means for whatever reason, we've already executed | ||||||
|  | 			// past the command we need to execute. | ||||||
|  | 			DEBUG(net, 0)("[NET] Trying to execute a packet in the past!"); | ||||||
|  | 			assert(0); | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		// We can execute this command | 		// We can execute this command | ||||||
| 		NetworkExecuteCommand(cp); | 		NetworkExecuteCommand(cp); | ||||||
|  |  | ||||||
| 				if (cp_prev != NULL) { | 		*cp_prev = cp->next; | ||||||
| 					cp_prev->next = cp->next; |  | ||||||
| 		free(cp); | 		free(cp); | ||||||
| 					cp = cp_prev->next; |  | ||||||
| 				} else { |  | ||||||
| 					// This means we are at our first packet |  | ||||||
| 					_local_command_queue = cp->next; |  | ||||||
| 					free(cp); |  | ||||||
| 					cp = _local_command_queue; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 			} else { | 	// Just a safety check, to be removed in the future. | ||||||
| 				// Command is in the future, skip to next | 	// Make sure that no older command appears towards the end of the queue | ||||||
| 				//  (commands don't have to be in order in the queue!!) | 	// In that case we missed executing it. This will never happen. | ||||||
| 				cp_prev = cp; | 	for(cp = _local_command_queue; cp; cp = cp->next) { | ||||||
| 				cp = cp->next; | 		assert(_frame_counter < cp->frame); | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static bool NetworkDoClientLoop(void) | static bool NetworkDoClientLoop(void) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ludde
					ludde