Diff on source/core/gameinput.cpp from commit ea17352ae

Diff on source/core/gameinput.cpp from commit ea17352ae

Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Old version: Lines 30-35New version: Lines 30-36
30
31
32
CVARD(Bool, invertmousex, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert horizontal mouse movement")
CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertical mouse movement")

30
31
32
CVARD(Bool, invertmousex, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert horizontal mouse movement")
CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertical mouse movement")

33

33
34
35
//---------------------------------------------------------------------------
//
// code fron gameexec/conrun
34
35
36
//---------------------------------------------------------------------------
//
// code fron gameexec/conrun
void resetTurnHeldAmt()
Old version: Lines 148-153New version: Lines 149-155
148
149
150
	turnheldtime = 0;
}

149
150
151
	turnheldtime = 0;
}

152

151
152
153
//---------------------------------------------------------------------------
//
// Player's movement function, called from game's ticker or from gi->GetInput() as required.
153
154
155
//---------------------------------------------------------------------------
//
// Player's movement function, called from game's ticker or from gi->GetInput() as required.
SW:   3 * 1.40625 * 40 = 168.75; // Precisely, ((((3 * 12) + ((3 * 12) / 4)) * 3
Old version: Lines 177-188New version: Lines 179-188
177
178
179
Average: 234.375;
*/

179
180
181
Average: 234.375;
*/

180
181
182
183
184
185
enum
{
RUNNINGTURNBASE = 1549,
NORMALTURNBASE = 891,
PREAMBLEBASE = 234,
};
182
183
184
185
static constexpr double RUNNINGTURNBASE = 1548.75;
static constexpr double NORMALTURNBASE = 890.625;
static constexpr double PREAMBLEBASE = 234.375;
static constexpr double PREAMBLESCALE = PREAMBLEBASE / NORMALTURNBASE;
186
187
188

void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt, bool const allowstrafe, double const turnscale)
{
186
187
188

void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt, bool const allowstrafe, double const turnscale)
{
void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
Old version: Lines 195-208New version: Lines 195-208
195
196
197

// process mouse and initial controller input.
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
195
196
197

// process mouse and initial controller input.
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
198
		currInput->svel -= xs_CRoundToInt(((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove)) * hidprescale);
198
		currInput->svel -= int16_t(((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove)) * hidprescale);
199
200
201
202
203
204
	else
currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed * turnscale));

if (!(inputBuffer->actions & SB_AIMMODE))
currInput->horz -= hidInput->mouseturny;
else
199
200
201
202
203
204
	else
currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed * turnscale));

if (!(inputBuffer->actions & SB_AIMMODE))
currInput->horz -= hidInput->mouseturny;
else
205
		currInput->fvel -= xs_CRoundToInt(hidInput->mousemovey * mousevelscale * hidprescale);
205
		currInput->fvel -= int16_t(hidInput->mousemovey * mousevelscale * hidprescale);
206
207
208

if (invertmouse)
currInput->horz = -currInput->horz;
206
207
208

if (invertmouse)
currInput->horz = -currInput->horz;
Old version: Lines 212-219New version: Lines 212-219
212
213
214

// process remaining controller input.
currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed);
212
213
214

// process remaining controller input.
currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed);
215
216
	currInput->svel += xs_CRoundToInt(scaleAdjust * hidInput->dx * keymove * hidprescale);
currInput->fvel += xs_CRoundToInt(scaleAdjust * hidInput->dz * keymove * hidprescale);
215
216
	currInput->svel += int16_t(scaleAdjust * hidInput->dx * keymove * hidprescale);
currInput->fvel += int16_t(scaleAdjust * hidInput->dz * keymove * hidprescale);
217
218
219

// process keyboard turning keys.
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
217
218
219

// process keyboard turning keys.
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
Old version: Lines 235-241New version: Lines 235-241
235
236
237
		if (turnleft || turnright)
{
updateTurnHeldAmt(scaleAdjust);
235
236
237
		if (turnleft || turnright)
{
updateTurnHeldAmt(scaleAdjust);
238
			float const turnamount = float(scaleAdjust * hidspeed * turnscale * (isTurboTurnTime() ? 1. : double(PREAMBLEBASE) / double(NORMALTURNBASE)));
238
			float const turnamount = float(scaleAdjust * hidspeed * turnscale * (isTurboTurnTime() ? 1. : PREAMBLESCALE));
239
240
241

if (turnleft)
currInput->avel -= turnamount;
239
240
241

if (turnleft)
currInput->avel -= turnamount;
enum
Old version: Lines 323-329New version: Lines 323-329
323
324
325

void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double const scaleAdjust)
{
323
324
325

void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double const scaleAdjust)
{
326
	// Process only if movewment isn't locked.
326
	// Process only if movement isn't locked.
327
328
329
	if (!movementlocked())
{
// Test if we have input to process.
327
328
329
	if (!movementlocked())
{
// Test if we have input to process.
void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double cons
Old version: Lines 374-379New version: Lines 374-380
374
375
376
	}
}

374
375
376
	}
}

377

377
378
379
//---------------------------------------------------------------------------
//
// Player's angle function, called from game's ticker or from gi->GetInput() as required.
378
379
380
//---------------------------------------------------------------------------
//
// Player's angle function, called from game's ticker or from gi->GetInput() as required.
Blood:    128 * 30 = 3840;
Old version: Lines 401-409New version: Lines 402-412
401
402
403
Blood:     64 * 30 = 1920;
*/

402
403
404
Blood:     64 * 30 = 1920;
*/

405
406
407
static constexpr double ROTRETURNSPEED  = (1. / 2.) * 30.;
static constexpr double LOOKRETURNSPEED = (1. / 4.) * 30.;

404
405
enum
{
408
409
enum
{
406
	LOOKROTRETBASE = 15,
407
408
409
	ROTATESPEED = 720,
LOOKINGSPEED = 4560,
SPINSTAND = 3840,
410
411
412
	ROTATESPEED = 720,
LOOKINGSPEED = 4560,
SPINSTAND = 3840,
enum
Old version: Lines 413-420New version: Lines 416-423
413
414
415
void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const scaleAdjust)
{
// Process angle return to zeros.
416
417
418
void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const scaleAdjust)
{
// Process angle return to zeros.
416
417
	scaletozero(rotscrnang, LOOKROTRETBASE, scaleAdjust);
scaletozero(look_ang, +LOOKROTRETBASE * 0.5, scaleAdjust);
419
420
	scaletozero(rotscrnang, ROTRETURNSPEED, scaleAdjust);
scaletozero(look_ang, LOOKRETURNSPEED, scaleAdjust);
418
419
420

// Process keyboard input.
auto doLookKeys = [&](ESyncBits_ const key, double const direction)
421
422
423

// Process keyboard input.
auto doLookKeys = [&](ESyncBits_ const key, double const direction)
void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const
Old version: Lines 466-471New version: Lines 469-475
466
467
468
	}
}

469
470
471
	}
}

472

469
470
471
//---------------------------------------------------------------------------
//
// Player's slope tilt when playing without a mouse and on a slope.
473
474
475
//---------------------------------------------------------------------------
//
// Player's slope tilt when playing without a mouse and on a slope.
SW:   (1 / 8) * 40 = 5;
Old version: Lines 479-484New version: Lines 483-490
479
480
481
Average: 4.375;
*/

483
484
485
Average: 4.375;
*/

486
487
static constexpr double HORIZOFFSPEED = (1. / 8.) * 35.;

482
483
484
enum
{
// Values used by Duke/SW, where this function originated from.
488
489
490
enum
{
// Values used by Duke/SW, where this function originated from.
void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con
Old version: Lines 518-524New version: Lines 524-530
518
519
520
				// accordingly
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, x, y) - k) <= (4 << 8)))
{
524
525
526
				// accordingly
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, x, y) - k) <= (4 << 8)))
{
521
					horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood() ? DEFVIEWPITCH : BLOODVIEWPITCH))));
527
					horizoff += q16horiz(fixed_t(scaleAdjust * ((j - k) * (!isBlood() ? DEFVIEWPITCH : BLOODVIEWPITCH))));
522
523
524
				}
}
}
528
529
530
				}
}
}
Old version: Lines 526-541New version: Lines 532-554
526
527
528
		if (climbing)
{
// tilt when climbing but you can't even really tell it.
532
533
534
		if (climbing)
{
// tilt when climbing but you can't even really tell it.
529
			if (horizoff.asq16() < IntToFixed(100)) horizoff += getscaledhoriz(4.375, scaleAdjust, buildhoriz(100) - horizoff, 1.);
535
			if (horizoff.asq16() < IntToFixed(100)) horizoff += getscaledhoriz(HORIZOFFSPEED, scaleAdjust, buildhoriz(100) - horizoff, 1.);
530
531
532
533
		}
else
{
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
536
537
538
539
		}
else
{
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
534
			scaletozero(horizoff, 4.375, scaleAdjust, Sgn(horizoff.asq16()));
540
			scaletozero(horizoff, HORIZOFFSPEED, scaleAdjust, Sgn(horizoff.asq16()));
535
536
537
538
		}
}
}

541
542
543
544
		}
}
}

545
546
547
548
549
550
551

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------

539
540
541
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def)
{
if (arc.BeginObject(keyname))
552
553
554
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def)
{
if (arc.BeginObject(keyname))