Bug Tracker – Attachment #226: Better sector prediction for bug #18

View | Details | Raw Unified | Return to bug 18
Collapse All | Expand All

(-)client/src/cl_main.cpp (-11 / +32 lines)
Lines 1147-1153 Link Here
1147
	p.real_velocity[1] = MSG_ReadLong();
1147
	p.real_velocity[1] = MSG_ReadLong();
1148
	p.real_velocity[2] = MSG_ReadLong();
1148
	p.real_velocity[2] = MSG_ReadLong();
1149
1149
1150
	real_plats.clear();
1150
	//real_plats.clear();
1151
}
1151
}
1152
1152
1153
void CL_ResendSvGametic(void)
1153
void CL_ResendSvGametic(void)
Lines 1762-1781 Link Here
1762
{
1762
{
1763
	int tic = MSG_ReadLong();
1763
	int tic = MSG_ReadLong();
1764
	unsigned short s = (unsigned short)MSG_ReadShort();
1764
	unsigned short s = (unsigned short)MSG_ReadShort();
1765
	unsigned long fh = MSG_ReadLong(); // floor height
1765
    fixed_t fh = MSG_ReadLong(); // floor height
1766
	MSG_ReadLong(); // ceiling height
1766
    fixed_t ch = MSG_ReadLong(); // ceiling height
1767
	byte state = MSG_ReadByte();
1767
    byte Type = MSG_ReadByte();
1768
	int count = MSG_ReadLong();
1769
1768
1770
/*
1769
	plat_pred_t pred = {s, tic, fh, ch};
1770
1771
	switch(Type)
1772
	{
1773
	    case 0:
1774
	    {
1775
            pred.m_Speed = MSG_ReadLong();
1776
            pred.m_Low = MSG_ReadLong();
1777
            pred.m_High = MSG_ReadLong();
1778
            pred.m_Wait = MSG_ReadLong();
1779
            pred.m_Count = MSG_ReadLong();
1780
            pred.m_Status = MSG_ReadLong();
1781
            pred.m_OldStatus = MSG_ReadLong();
1782
            pred.m_Crush = MSG_ReadBool();
1783
            pred.m_Tag = MSG_ReadLong();
1784
            pred.m_Type = MSG_ReadLong();
1785
            pred.m_PostWait = MSG_ReadBool();
1786
	    }
1787
	    break;
1788
1789
	    default:
1790
            return;
1791
	}
1792
	
1771
	if(!sectors || s >= numsectors)
1793
	if(!sectors || s >= numsectors)
1772
		return;
1794
		return;
1773
1795
1774
	plat_pred_t pred = {s, state, count, tic, fh};
1796
	sector_t *sec = &sectors[s];
1775
//	sector_t *sec = &sectors[s];
1776
1797
1777
//	if(!sec->floordata)
1798
	if(!sec->floordata)
1778
//		sec->floordata = new DMovingFloor(sec);
1799
		sec->floordata = new DPlat(sec);
1779
1800
1780
	size_t i;
1801
	size_t i;
1781
1802
Lines 1789-1795 Link Here
1789
	}
1810
	}
1790
1811
1791
	if(i == real_plats.size())
1812
	if(i == real_plats.size())
1792
		real_plats.push_back(pred);*/
1813
		real_plats.push_back(pred);
1793
}
1814
}
1794
1815
1795
1816
(-)client/src/cl_main.h (-4 / +14 lines)
Lines 45-56 Link Here
45
struct plat_pred_t
45
struct plat_pred_t
46
{
46
{
47
	size_t secnum;
47
	size_t secnum;
48
49
	byte state;
50
	int count;
51
	int tic;
48
	int tic;
52
49
53
	unsigned long floorheight;
50
    fixed_t floorheight;
51
    fixed_t ceilingheight;
52
53
	fixed_t 	m_Speed;
54
	fixed_t 	m_Low;
55
	fixed_t 	m_High;
56
	int 		m_Wait;
57
	int 		m_Count;
58
	int	        m_Status;
59
	int     	m_OldStatus;
60
	bool 		m_Crush;
61
	int 		m_Tag;
62
	int     	m_Type;
63
	bool		m_PostWait;
54
};
64
};
55
65
56
extern std::vector <plat_pred_t> real_plats;
66
extern std::vector <plat_pred_t> real_plats;
(-)client/src/cl_pred.cpp (-15 / +48 lines)
Lines 71-84 Link Here
71
71
72
		if(sec->floordata->IsKindOf(RUNTIME_CLASS(DPlat)))
72
		if(sec->floordata->IsKindOf(RUNTIME_CLASS(DPlat)))
73
		{
73
		{
74
			DPlat *plat = (DPlat *)sec->floordata;
74
			DPlat *Plat = (DPlat *)sec->floordata;
75
			sec->floorheight = pred->floorheight;
75
76
			plat->SetState(pred->state, pred->count);
76
            sec->floorheight = pred->floorheight;
77
            sec->ceilingheight = pred->ceilingheight;
78
79
            Plat->m_Speed = pred->m_Speed;
80
            Plat->m_Low = pred->m_Low;
81
            Plat->m_High = pred->m_High;
82
            Plat->m_Wait = pred->m_Wait;
83
            Plat->m_Count = pred->m_Count;
84
            Plat->m_Status = (DPlat::EPlatState)pred->m_Status;
85
            Plat->m_OldStatus = (DPlat::EPlatState)pred->m_OldStatus;
86
            Plat->m_Crush = pred->m_Crush;
87
            Plat->m_Tag = pred->m_Tag;
88
            Plat->m_Type = (DPlat::EPlatType)pred->m_Type;
89
            Plat->m_PostWait = pred->m_PostWait;
77
		}
90
		}
78
		else if(sec->floordata && sec->floordata->IsKindOf(RUNTIME_CLASS(DMovingFloor)))
79
		{
80
			sec->floorheight = pred->floorheight;
81
		}
82
	}
91
	}
83
}
92
}
84
93
Lines 94-103 Link Here
94
103
95
		if(pred->tic < predtic)
104
		if(pred->tic < predtic)
96
		{
105
		{
97
			if(sec->floordata && (sec->floordata->IsKindOf(RUNTIME_CLASS(DPlat))
106
			if(sec->floordata && sec->floordata->IsKindOf(RUNTIME_CLASS(DPlat)))
98
				|| sec->floordata->IsKindOf(RUNTIME_CLASS(DMovingFloor))))
99
			{
107
			{
100
				sec->floordata->RunThink();
108
                sec->floordata->RunThink();
101
			}
109
			}
102
		}
110
		}
103
	}
111
	}
Lines 147-152 Link Here
147
	}
155
	}
148
	else
156
	else
149
	{
157
	{
158
        // [Russell] - Unsure if its good to call this all the time, but it does 
159
        // smooth out the viewheight pogo
160
        CL_MoveThing(p->mo, p->mo->x, p->mo->y, p->mo->z);
150
		P_MovePlayer(p);
161
		P_MovePlayer(p);
151
		P_CalcHeight(p);
162
		P_CalcHeight(p);
152
	}
163
	}
Lines 198-204 Link Here
198
}
209
}
199
210
200
//
211
//
201
// CL_PredicMove
212
// CL_PredictMove
202
//
213
//
203
void CL_PredictMove (void)
214
void CL_PredictMove (void)
204
{
215
{
Lines 210-215 Link Here
210
	if (!p->tic || !p->mo)
221
	if (!p->tic || !p->mo)
211
		return;
222
		return;
212
223
224
    #ifdef _PRED_DBG
225
    fixed_t origx, origy, origz;
226
    #endif
227
213
	// Save player angle, viewheight,deltaviewheight and jumpTics.
228
	// Save player angle, viewheight,deltaviewheight and jumpTics.
214
	// Will use it later to predict movements
229
	// Will use it later to predict movements
215
	cl_angle[gametic%MAXSAVETICS] = p->mo->angle;
230
	cl_angle[gametic%MAXSAVETICS] = p->mo->angle;
Lines 219-224 Link Here
219
	cl_jumpTics[gametic%MAXSAVETICS] = p->jumpTics;
234
	cl_jumpTics[gametic%MAXSAVETICS] = p->jumpTics;
220
	cl_reactiontime[gametic%MAXSAVETICS] = p->mo->reactiontime;
235
	cl_reactiontime[gametic%MAXSAVETICS] = p->mo->reactiontime;
221
236
237
    #ifdef _PRED_DBG
238
    // Backup original position
239
	origx = p->mo->x;
240
	origy = p->mo->y;
241
	origz = p->mo->z;
242
    #endif
243
    
222
	// Disable sounds, etc, during prediction
244
	// Disable sounds, etc, during prediction
223
	predicting = true;
245
	predicting = true;
224
246
Lines 232-249 Link Here
232
		predtic = 0;
254
		predtic = 0;
233
255
234
	// Predict each tic
256
	// Predict each tic
235
	while(predtic < gametic)
257
	while(++predtic < gametic)
236
	{
258
	{
237
		CL_PredictPlayers(predtic);
259
		CL_PredictPlayers(predtic);
238
		CL_PredictSectors(predtic);
260
		CL_PredictSectors(predtic);
239
240
		++predtic;
241
	}
261
	}
242
262
243
	predicting = false;
263
	predicting = false;
244
264
245
	CL_PredictPlayers(predtic);
265
	CL_PredictPlayers(predtic);
246
	CL_PredictSectors(predtic);
266
	// [Russell] - I don't think we need to call this as DThinker::RunThinkers()
267
	// will already run the platform thinkers after prediction
268
    //CL_PredictSectors(predtic);
269
    
270
    #ifdef _PRED_DBG
271
	if ((origx == p->mo->x) && (origy == p->mo->y) && (origz == p->mo->z))
272
    {
273
        Printf(PRINT_HIGH, "%d tics predicted\n", predtic);
274
    }
275
    else
276
    {
277
        Printf(PRINT_HIGH, "%d tics failed\n", predtic);
278
    }
279
    #endif
247
}
280
}
248
281
249
VERSION_CONTROL (cl_pred_cpp, "$Id$")
282
VERSION_CONTROL (cl_pred_cpp, "$Id$")
(-)common/p_plats.cpp (-2 / +7 lines)
Lines 93-99 Link Here
93
			m_Count = m_Wait;
93
			m_Count = m_Wait;
94
			m_Status = down;
94
			m_Status = down;
95
			//PlayPlatSound ("Platform");
95
			//PlayPlatSound ("Platform");
96
			S_Sound (m_Sector->soundorg, CHAN_BODY, "plats/pt1_strt", 1, ATTN_NORM);
96
			S_PlatSound (m_Sector->soundorg, CHAN_BODY, "plats/pt1_strt", 1, ATTN_NORM);
97
		}
97
		}
98
		else if (res == pastdest)
98
		else if (res == pastdest)
99
		{
99
		{
Lines 185-191 Link Here
185
			*/
185
			*/
186
			if(!m_PostWait)
186
			if(!m_PostWait)
187
			{
187
			{
188
				S_Sound (m_Sector->soundorg, CHAN_BODY, "plats/pt1_strt", 1, ATTN_NORM);
188
				S_PlatSound (m_Sector->soundorg, CHAN_BODY, "plats/pt1_strt", 1, ATTN_NORM);
189
				m_PostWait = true;
189
				m_PostWait = true;
190
			}
190
			}
191
		}
191
		}
Lines 227-232 Link Here
227
	int rtn = false;
227
	int rtn = false;
228
	BOOL manual = false;
228
	BOOL manual = false;
229
229
230
	// [Russell] - Disable activating platforms from the server
231
	// the prediction will handle everything
232
    if (clientside && network_game)
233
        return rtn;
234
230
	// [RH] If tag is zero, use the sector on the back side
235
	// [RH] If tag is zero, use the sector on the back side
231
	//		of the activating line (if any).
236
	//		of the activating line (if any).
232
	if (!tag)
237
	if (!tag)
(-)common/p_spec.h (-1 / +1 lines)
Lines 445-451 Link Here
445
	void SetState(byte state, int count) { m_Status = (EPlatState)state; m_Count = count; }
445
	void SetState(byte state, int count) { m_Status = (EPlatState)state; m_Count = count; }
446
	void GetState(byte &state, int &count) { state = (byte)m_Status; count = m_Count; }
446
	void GetState(byte &state, int &count) { state = (byte)m_Status; count = m_Count; }
447
447
448
protected:
449
	DPlat (sector_t *sector);
448
	DPlat (sector_t *sector);
450
449
451
	fixed_t 	m_Speed;
450
	fixed_t 	m_Speed;
Lines 459-464 Link Here
459
	int 		m_Tag;
458
	int 		m_Tag;
460
	EPlatType	m_Type;
459
	EPlatType	m_Type;
461
	bool		m_PostWait;
460
	bool		m_PostWait;
461
protected:
462
462
463
	void PlayPlatSound (const char *sound);
463
	void PlayPlatSound (const char *sound);
464
	void Reactivate ();
464
	void Reactivate ();
(-)server/src/sv_main.cpp (-17 / +14 lines)
Lines 1506-1531 Link Here
1506
				MSG_WriteLong (&cl->netbuf, cl->lastclientcmdtic);
1506
				MSG_WriteLong (&cl->netbuf, cl->lastclientcmdtic);
1507
				MSG_WriteShort (&cl->netbuf, s);
1507
				MSG_WriteShort (&cl->netbuf, s);
1508
				MSG_WriteLong (&cl->netbuf, sec->floorheight);
1508
				MSG_WriteLong (&cl->netbuf, sec->floorheight);
1509
				MSG_WriteLong (&cl->netbuf, sec->ceilingheight);
1509
                MSG_WriteLong (&cl->netbuf, sec->ceilingheight);
1510
                MSG_WriteByte (&cl->netbuf, 0);
1510
1511
1511
				DPlat *plat = (DPlat *)sec->floordata;
1512
				DPlat *Plat = (DPlat *)sec->floordata;
1512
				byte state; int count;
1513
				plat->GetState(state, count);
1514
1513
1515
				MSG_WriteByte (&cl->netbuf, state);
1514
                MSG_WriteLong(&cl->netbuf, Plat->m_Speed);
1516
				MSG_WriteLong (&cl->netbuf, count);
1515
                MSG_WriteLong(&cl->netbuf, Plat->m_Low);
1516
                MSG_WriteLong(&cl->netbuf, Plat->m_High);
1517
                MSG_WriteLong(&cl->netbuf, Plat->m_Wait);
1518
                MSG_WriteLong(&cl->netbuf, Plat->m_Count);
1519
                MSG_WriteLong(&cl->netbuf, Plat->m_Status);
1520
                MSG_WriteLong(&cl->netbuf, Plat->m_OldStatus);
1521
                MSG_WriteBool(&cl->netbuf, Plat->m_Crush);
1522
                MSG_WriteLong(&cl->netbuf, Plat->m_Tag);
1523
                MSG_WriteLong(&cl->netbuf, Plat->m_Type);
1524
                MSG_WriteBool(&cl->netbuf, Plat->m_PostWait);
1517
			}
1525
			}
1518
			else if(sec->floordata->IsKindOf(RUNTIME_CLASS(DMovingFloor)))
1519
			{
1520
				MSG_WriteMarker (&cl->netbuf, svc_movingsector);
1521
				MSG_WriteLong (&cl->netbuf, cl->lastclientcmdtic);
1522
				MSG_WriteShort (&cl->netbuf, s);
1523
				MSG_WriteLong (&cl->netbuf, sec->floorheight);
1524
				MSG_WriteLong (&cl->netbuf, sec->ceilingheight);
1525
1526
				MSG_WriteByte (&cl->netbuf, 0);
1527
				MSG_WriteLong (&cl->netbuf, 0);
1528
			}
1529
		}
1526
		}
1530
	}
1527
	}
1531
}
1528
}

Return to bug 18