Skip to content

Commit c9d31a3

Browse files
committed
Test stubs is nearly done
1 parent 5160b9c commit c9d31a3

File tree

7 files changed

+47
-164
lines changed

7 files changed

+47
-164
lines changed

client/sdl/i_system.h

-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ void I_EndRead (void);
5151
void I_Init (void);
5252
void I_Endoom(void);
5353

54-
// Called by startup code
55-
// to get the ammount of memory to malloc
56-
// for the zone management.
57-
void *I_ZoneBase (size_t *size);
58-
59-
6054
// returns current time in nanoseconds.
6155
dtime_t I_GetTime();
6256

client/src/r_plane.cpp

-41
Original file line numberDiff line numberDiff line change
@@ -738,45 +738,4 @@ bool R_PlaneInitData(IWindowSurface* surface)
738738
return true;
739739
}
740740

741-
//
742-
// R_AlignFlat
743-
//
744-
bool R_AlignFlat (int linenum, int side, int fc)
745-
{
746-
line_t *line = lines + linenum;
747-
sector_t *sec = side ? line->backsector : line->frontsector;
748-
749-
if (!sec)
750-
return false;
751-
752-
fixed_t x = line->v1->x;
753-
fixed_t y = line->v1->y;
754-
755-
angle_t angle = R_PointToAngle2 (x, y, line->v2->x, line->v2->y);
756-
angle_t norm = (angle-ANG90) >> ANGLETOFINESHIFT;
757-
758-
fixed_t dist = -FixedMul (finecosine[norm], x) - FixedMul (finesine[norm], y);
759-
760-
if (side)
761-
{
762-
angle = angle + ANG180;
763-
dist = -dist;
764-
}
765-
766-
if (fc)
767-
{
768-
sec->base_ceiling_angle = 0-angle;
769-
sec->base_ceiling_yoffs = dist & ((1<<(FRACBITS+8))-1);
770-
sec->SectorChanges |= SPC_AlignBase;
771-
}
772-
else
773-
{
774-
sec->base_floor_angle = 0-angle;
775-
sec->base_floor_yoffs = dist & ((1<<(FRACBITS+8))-1);
776-
sec->SectorChanges |= SPC_AlignBase;
777-
}
778-
779-
return true;
780-
}
781-
782741
VERSION_CONTROL (r_plane_cpp, "$Id$")
File renamed without changes.

server/src/i_system.h

-6
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ void I_EndRead (void);
5252
// Called by DoomMain.
5353
void I_Init (void);
5454

55-
// Called by startup code
56-
// to get the ammount of memory to malloc
57-
// for the zone management.
58-
void *I_ZoneBase (size_t *size);
59-
60-
6155
dtime_t I_GetTime();
6256
dtime_t I_ConvertTimeToMs(dtime_t value);
6357
dtime_t I_ConvertTimeFromMs(dtime_t value);

tests/unit-tests/src/i_system.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,8 @@ size_t I_BytesToMegabytes (size_t Bytes)
9797
return (Bytes/1024/1024);
9898
}
9999

100-
void I_BeginRead(void)
101-
{
102-
}
103-
104-
void I_EndRead(void)
105-
{
106-
}
100+
void I_BeginRead(void) {}
101+
void I_EndRead(void) {}
107102

108103
//
109104
// I_GetTime
@@ -266,9 +261,7 @@ void SetLanguageIDs()
266261
//
267262
// I_Init
268263
//
269-
void I_Init (void)
270-
{
271-
}
264+
void I_Init (void) {}
272265

273266
void I_FinishClockCalibration ()
274267
{

tests/unit-tests/src/i_system.h

-6
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ void I_EndRead (void);
4949
// Called by DoomMain.
5050
void I_Init (void);
5151

52-
// Called by startup code
53-
// to get the ammount of memory to malloc
54-
// for the zone management.
55-
void *I_ZoneBase (size_t *size);
56-
57-
5852
dtime_t I_GetTime();
5953
dtime_t I_ConvertTimeToMs(dtime_t value);
6054
dtime_t I_ConvertTimeFromMs(dtime_t value);

tests/unit-tests/src/t_stubs.cpp

+44-95
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,25 @@ CVAR (sv_maxplayers, "0", "maximum players who can join the game, others are sp
6060
void C_AddTabCommand(char const *) {}
6161
void C_RemoveTabCommand(char const *) {}
6262
void P_ShowSpawns(MapThing*) {}
63+
void P_SpawnPlayer(player_t&, mapthing2_t*) {}
6364
void G_DeathMatchSpawnPlayer(player_t&) {}
64-
player_t& consoleplayer() { static player_t fake{}; return fake; }
65-
player_t& displayplayer() { static player_t fake{}; return fake; }
65+
player_t& consoleplayer() { return idplayer(consoleplayer_id); }
66+
player_t& displayplayer() { return idplayer(displayplayer_id); }
6667

6768
void BuildDefaultShademap(palette_t const *, shademap_t &) {}
6869
palindex_t V_BestColor(const argb_t* palette_colors, int r, int g, int b) { return 0; }
6970
palindex_t V_BestColor(const argb_t *palette_colors, argb_t color) { return 0; }
70-
bool R_AlignFlat(int,int,int) { return false; }
71+
72+
argb_t V_GetColorFromString(const std::string& str)
73+
{
74+
return 0;
75+
}
76+
77+
const palette_t* V_GetDefaultPalette()
78+
{
79+
static palette_t default_palette;
80+
return &default_palette;
81+
}
7182

7283
void D_SendServerInfoChange(const cvar_t *cvar, const char *value) {}
7384
void D_DoServerInfoChange(byte **stream) {}
@@ -106,11 +117,6 @@ void R_ExitLevel() {}
106117
void D_SetupUserInfo (void) {}
107118
void D_UserInfoChanged (cvar_t *cvar) {}
108119

109-
argb_t V_GetColorFromString(const std::string& str)
110-
{
111-
return 0;
112-
}
113-
114120
void PickupMessage(AActor *toucher, const char *message) {}
115121
void WeaponPickupMessage(AActor *toucher, weapontype_t &Weapon) {}
116122

@@ -120,38 +126,18 @@ void RefreshPalettes (void) {}
120126

121127
void V_RefreshColormaps() {}
122128

123-
size_t C_BasePrint(const int printlevel, const char* color_code, const std::string& str) { return 0; }
129+
void C_MidPrint (const char *msg, player_t *p, int msgtime) {}
130+
size_t C_BasePrint(const int printlevel, const char* color_code, const std::string& str) { fmt::print(str); }
124131

125-
//
126-
// [RH] Print sound debug info. Called from D_Display()
127-
//
128132
void S_NoiseDebug() {}
129-
130-
131-
//
132-
// Internals.
133-
//
134-
135-
//
136-
// Initializes sound stuff, including volume
137-
// Sets channels, SFX and music volume,
138-
// allocates channel buffer, sets S_sfx lookup.
139-
//
140-
void S_Init(float sfxVolume, float musicVolume)
141-
{
142-
// [RH] Read in sound sequences
143-
//NumSequences = 0;
144-
}
145-
133+
void S_Init(float sfxVolume, float musicVolume) {}
146134
void S_Start() {}
147135
void S_Stop() {}
148136
void S_SoundID(int channel, int sound_id, float volume, int attenuation) {}
149137
void S_SoundID(AActor *ent, int channel, int sound_id, float volume, int attenuation) {}
150138
void S_SoundID(fixed_t *pt, int channel, int sound_id, float volume, int attenuation) {}
151139
void S_LoopedSoundID(AActor *ent, int channel, int sound_id, float volume, int attenuation) {}
152140
void S_LoopedSoundID(fixed_t *pt, int channel, int sound_id, float volume, int attenuation) {}
153-
154-
// [Russell] - Hack to stop multiple plat stop sounds
155141
void S_PlatSound(fixed_t *pt, int channel, const char *name, float volume, int attenuation) {}
156142
void S_Sound(int channel, const char *name, float volume, int attenuation) {}
157143
void S_Sound(AActor *ent, int channel, const char *name, float volume, int attenuation) {}
@@ -163,49 +149,20 @@ void S_StopSound(fixed_t *pt) {}
163149
void S_StopSound(fixed_t *pt, int channel) {}
164150
void S_StopSound(AActor *ent, int channel) {}
165151
void S_StopAllChannels() {}
166-
167-
// Moves all the sounds from one thing to another. If the destination is
168-
// NULL, then the sound becomes a positioned sound.
169152
void S_RelinkSound(AActor *from, AActor *to) {}
170-
171-
bool S_GetSoundPlayingInfo(fixed_t *pt, int sound_id)
172-
{
173-
return false;
174-
}
175-
176-
bool S_GetSoundPlayingInfo(AActor *ent, int sound_id)
177-
{
178-
return S_GetSoundPlayingInfo (ent ? &ent->x : NULL, sound_id);
179-
}
180-
181-
//
182-
// Stop and resume music, during game PAUSE.
183-
//
153+
bool S_GetSoundPlayingInfo(fixed_t *pt, int sound_id) { return false; }
154+
bool S_GetSoundPlayingInfo(AActor *ent, int sound_id) { return S_GetSoundPlayingInfo (ent ? &ent->x : NULL, sound_id); }
184155
void S_PauseSound() {}
185-
186156
void S_ResumeSound() {}
187-
188-
//
189-
// Updates music & sounds
190-
//
191157
void S_UpdateSounds(void *listener_p) {}
192-
193158
void S_UpdateMusic() {}
194-
195159
void S_SetMusicVolume(float volume) {}
196-
197160
void S_SetSfxVolume(float volume) {}
198-
199-
//
200-
// Starts some music with the music id found in sounds.h.
201-
//
202161
void S_StartMusic(const char *m_id) {}
203-
204-
// [RH] S_ChangeMusic() now accepts the name of the music lump.
205-
// It's up to the caller to figure out what that name is.
206162
void S_ChangeMusic(std::string musicname, bool looping) {}
207-
208163
void S_StopMusic() {}
164+
void A_Ambient(AActor *actor) {}
165+
void S_ActivateAmbient(AActor *origin, int ambient) {}
209166

210167

211168
// [RH] ===============================
@@ -527,9 +484,6 @@ void S_ParseSndInfo()
527484
S_HashSounds();
528485
}
529486

530-
void A_Ambient(AActor *actor) {}
531-
void S_ActivateAmbient(AActor *origin, int ambient) {}
532-
533487
void AM_SetBaseColorDoom() {}
534488
void AM_SetBaseColorRaven() {}
535489
void AM_SetBaseColorStrife() {}
@@ -549,10 +503,22 @@ void SV_OnActivatedLine(line_t* line, AActor* mo, const int side,
549503
const LineActivationType activationType, const bool bossaction) {}
550504
void UV_SoundAvoidPlayer(AActor *mo, byte channel, const char *name, byte attenuation) {}
551505
void OnChangedSwitchTexture (line_t *line, int useAgain) {}
552-
void C_MidPrint (const char *msg, player_t *p, int msgtime) {}
506+
507+
void R_RotatePoint(fixed_t x, fixed_t y, angle_t ang, fixed_t &tx, fixed_t &ty)
508+
{
509+
int index = ang >> ANGLETOFINESHIFT;
510+
511+
tx = FixedMul(x, finecosine[index]) - FixedMul(y, finesine[index]);
512+
ty = FixedMul(x, finesine[index]) + FixedMul(y, finecosine[index]);
513+
}
553514

554515
#define R_P2ATHRESHOLD (INT_MAX / 4)
555516

517+
angle_t R_PointToAngle (fixed_t x, fixed_t y)
518+
{
519+
return R_PointToAngle2 (viewx, viewy, x, y);
520+
}
521+
556522
angle_t R_PointToAngle2(fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y)
557523
{
558524
x -= viewx;
@@ -642,6 +608,7 @@ translationref_t::translationref_t(const translationref_t &other) : m_table(othe
642608
translationref_t::translationref_t(const byte *table) : m_table(table), m_player_id(-1) {}
643609
translationref_t::translationref_t(const byte *table, const int player_id) : m_table(table), m_player_id(player_id) {}
644610

611+
shaderef_t::shaderef_t() : m_colors(NULL), m_mapnum(-1), m_colormap(NULL), m_shademap(NULL) {}
645612
shaderef_t::shaderef_t(const shademap_t * const colors, const int mapnum) : m_colors(colors), m_mapnum(mapnum)
646613
{
647614
#if ODAMEX_DEBUG
@@ -692,28 +659,6 @@ shaderef_t::shaderef_t(const shademap_t * const colors, const int mapnum) : m_co
692659
}
693660
}
694661

695-
static palette_t default_palette;
696-
697-
const palette_t* V_GetDefaultPalette()
698-
{
699-
return &default_palette;
700-
}
701-
702-
void P_SpawnPlayer(player_t&, mapthing2_t*) {}
703-
void CTF_CheckFlags (player_t &player)
704-
{
705-
for(size_t i = 0; i < NUMTEAMS; i++)
706-
{
707-
if(player.flags[i])
708-
{
709-
player.flags[i] = false;
710-
GetTeamInfo((team_t)i)->FlagData.flagger = 0;
711-
}
712-
}
713-
}
714-
715-
shaderef_t::shaderef_t() : m_colors(NULL), m_mapnum(-1), m_colormap(NULL), m_shademap(NULL) {}
716-
717662
dyncolormap_t NormalLight;
718663

719664
dyncolormap_t *GetSpecialLights (int lr, int lg, int lb, int fr, int fg, int fb)
@@ -750,12 +695,16 @@ dyncolormap_t *GetSpecialLights (int lr, int lg, int lb, int fr, int fg, int fb)
750695
return colormap;
751696
}
752697

753-
void R_RotatePoint(fixed_t x, fixed_t y, angle_t ang, fixed_t &tx, fixed_t &ty)
698+
void CTF_CheckFlags (player_t &player)
754699
{
755-
int index = ang >> ANGLETOFINESHIFT;
756-
757-
tx = FixedMul(x, finecosine[index]) - FixedMul(y, finesine[index]);
758-
ty = FixedMul(x, finesine[index]) + FixedMul(y, finecosine[index]);
700+
for(size_t i = 0; i < NUMTEAMS; i++)
701+
{
702+
if(player.flags[i])
703+
{
704+
player.flags[i] = false;
705+
GetTeamInfo((team_t)i)->FlagData.flagger = 0;
706+
}
707+
}
759708
}
760709

761710
VERSION_CONTROL (test_stubs_cpp, "$Id$")

0 commit comments

Comments
 (0)