about summary refs log tree commit diff
path: root/src/engine/docs/prediction.txt
blob: d5771d1aa58ee7df7b439fff42158c675ce19ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Title: Prediction

The engine calls <modc_predict> when reprediction is required. This happens usally when new data has arrived from the server. <modc_predict> should to prediction from the current snapshot and current snapshot tick (<client_tick> + 1) upto and including the tick returned by <client_predtick>.

Predicted input sent to the server can be retrived by calling <client_get_input> with the corresponding tick that you want the input for. Here is a simple example of how it might look.

> void modc_predict()
> {
> 	int tick;
> 	prediction_reset();
> 
> 	for(tick = client_tick()+1; tick <= client_predtick(); tick++)
> 	{
> 		MY_INPUT *input = (MY_INPUT *)client_get_input();
> 		if(input)
> 			prediction_apply_input(input);
> 		prediction_tick();
> 	}
> }