Skip to content

Commit ea3a813

Browse files
committed
Fixed flag position bug and performed code cleanup
1 parent 0874111 commit ea3a813

File tree

103 files changed

+723
-755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+723
-755
lines changed

Freeserf.Audio/Audio.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System;
2-
using Freeserf.Data;
1+
using Freeserf.Data;
2+
using System;
33

44
namespace Freeserf.Audio
55
{

Freeserf.Audio/Bass/BassLib.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public unsafe DWORD Read(void* buffer, DWORD length, IntPtr user)
263263
{
264264
return 0u;
265265
}
266-
266+
267267
return (DWORD)numRead;
268268
}
269269

Freeserf.Audio/Bass/MidiMusic.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ namespace Freeserf.Audio.Bass
44
{
55
internal class MidiMusic : Music
66
{
7-
internal MidiMusic(XMI xmi)
8-
: base(LoadMidi(xmi))
9-
{
7+
internal MidiMusic(XMI xmi)
8+
: base(LoadMidi(xmi))
9+
{
1010

11-
}
11+
}
1212

1313
static uint GetControllerEventType(byte controller)
1414
{

Freeserf.Audio/Bass/MusicPlayer.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using Freeserf.Data;
1+
using Freeserf.Data;
32

43
namespace Freeserf.Audio.Bass
54
{

Freeserf.Audio/Bass/WaveMusic.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Freeserf.Audio.Bass
44
internal class WaveMusic : Music
55
{
66
internal WaveMusic(byte[] data)
7-
: base(data, Type.Sfx)
7+
: base(data, Type.Sfx)
88
{
99

1010
}

Freeserf.Core/AI.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ public void Update(Game game)
11401140
else
11411141
{
11421142
GameTime += game.Tick - lastTick;
1143-
}
1143+
}
11441144

11451145
if (states.Count == 0)
11461146
{
@@ -1200,7 +1200,7 @@ public static AI Read(SaveReaderText reader, Game game, bool firstAI)
12001200
void ReadFrom(SaveReaderText reader, Game game, bool firstAI)
12011201
{
12021202
int numStates = reader.Value("num_states").ReadInt();
1203-
1203+
12041204
for (int i = 0; i < numStates; ++i)
12051205
{
12061206
var state = AIState.Read(game, this, "state" + i, reader);

Freeserf.Core/AIStates/AIStateAdjustSettings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public override void Update(AI ai, Game game, Player player, PlayerInfo playerIn
4848
else if (numFreeKnights < 10 - ai.Aggressivity + (ai.MilitarySkill + ai.DefendFocus + 1) / 2)
4949
{
5050
--highKnightOccupationPreference;
51-
}
51+
}
5252
}
5353

5454
int defendingOrientation = Misc.Max(0, ai.DefendFocus - (ai.ExpandFocus + ai.Aggressivity + 1) / 2);

Freeserf.Core/AIStates/AIStateBuildBuilding.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void Search(object param)
111111
}
112112
finally
113113
{
114-
lock(state.searchingLock)
114+
lock (state.searchingLock)
115115
{
116116
state.searching = false;
117117
}
@@ -125,7 +125,7 @@ public override void Kill(AI ai)
125125
searching = false;
126126
}
127127

128-
base.Kill(ai);
128+
base.Kill(ai);
129129
}
130130

131131
public override void Update(AI ai, Game game, Player player, PlayerInfo playerInfo, int tick)
@@ -156,7 +156,7 @@ public override void Update(AI ai, Game game, Player player, PlayerInfo playerIn
156156
// With a fisher and enough fish, the pincer/hammer for weaponsmith has prio.
157157
// As the hammer might be consumed by another serf, we first craft the pincer.
158158
else
159-
{
159+
{
160160
player.SetFullToolPriority(Resource.Type.Pincer);
161161
}
162162
}

Freeserf.Core/AIStates/AIStateCheckNeededBuilding.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ CheckResult CheckBuilding(AI ai, Game game, Player player, int intelligence, Bui
339339
break;
340340
case Building.Type.Hut:
341341
if (player.GetIncompleteBuildingCount(Building.Type.Hut) == 0 &&
342-
game.HasAnyOfBuildingCompletedOrMaterialsAtPlace(player, Building.Type.Forester) &&
342+
game.HasAnyOfBuildingCompletedOrMaterialsAtPlace(player, Building.Type.Forester) &&
343343
!game.GetPlayerBuildings(player, Building.Type.Hut).Any(building => !building.HasKnight())
344344
&& ai.GameTime > count * 180 * Global.TICKS_PER_SEC && game.GetPossibleFreeKnightCount(player) > 0)
345345
return CheckResult.Needed;
@@ -356,15 +356,15 @@ CheckResult CheckBuilding(AI ai, Game game, Player player, int intelligence, Bui
356356
if (count == 0)
357357
return CheckResult.Needed;
358358
break;
359-
// If we have at least one coal and iron, we can build a steelsmelter and a toolmaker to produce a scythe or pincer.
360-
// This can happen with a bit more than minimum supplies or if the mines produce something without a food source.
361-
// We will craft a scythe if we can't build a fisher. We will craft a pincer and/or hammer if we have no more knights.
359+
// If we have at least one coal and iron, we can build a steelsmelter and a toolmaker to produce a scythe or pincer.
360+
// This can happen with a bit more than minimum supplies or if the mines produce something without a food source.
361+
// We will craft a scythe if we can't build a fisher. We will craft a pincer and/or hammer if we have no more knights.
362362
case Building.Type.ToolMaker:
363363
if (count == 0 && player.GetCompletedBuildingCount(Building.Type.SteelSmelter) != 0)
364364
return CheckResult.Needed;
365365
break;
366366
case Building.Type.SteelSmelter:
367-
if (count == 0 &&
367+
if (count == 0 &&
368368
(game.GetResourceAmountInInventories(player, Resource.Type.Coal) != 0 || player.GetCompletedBuildingCount(Building.Type.CoalMine) != 0) &&
369369
(game.GetResourceAmountInInventories(player, Resource.Type.IronOre) != 0 || player.GetCompletedBuildingCount(Building.Type.IronMine) != 0))
370370
return CheckResult.Needed;

Freeserf.Core/AIStates/AIStateChoosingCastleLocation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Map.FindData FindMineral(Map map, MapPos position)
131131
{
132132
return new Map.FindData()
133133
{
134-
Success = FindMountain(map, position).Success && map.GetResourceAmount(position) > 0u,
134+
Success = FindMountain(map, position).Success && map.GetResourceAmount(position) > 0u,
135135
Data = new KeyValuePair<Map.Minerals, uint>(map.GetResourceType(position), map.GetResourceAmount(position))
136136
};
137137
}

Freeserf.Core/AIStates/AIStateCraftTool.cs

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
* along with freeserf.net. If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121

22-
using System.Linq;
23-
2422
namespace Freeserf.AIStates
2523
{
2624
class AIStateCraftTool : AIState

Freeserf.Core/AIStates/AIStateIdle.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public override void Update(AI ai, Game game, Player player, PlayerInfo playerIn
121121
buildNeededBuildingState.Reset();
122122
ai.PushState(buildNeededBuildingState);
123123
}
124-
124+
125125
return;
126126
}
127127
}

Freeserf.Core/AIStates/AIStateLinkBuilding.cs

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
* along with freeserf.net. If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121

22-
using System;
23-
2422
namespace Freeserf.AIStates
2523
{
2624
class AIStateLinkBuilding : AIState

Freeserf.Core/AIStates/AIStateLinkDisconnectedFlags.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void LinkFlag(AI ai, Game game, Flag flag, List<object> nearbyFlags, int maxLeng
321321
}
322322
}
323323
}
324-
}
324+
}
325325
};
326326

327327
new Thread(new ParameterizedThreadStart(Link)).Start(action);

Freeserf.Core/Audio/IAudioInterface.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace Freeserf.Audio
1+
namespace Freeserf.Audio
62
{
73
public interface IAudioInterface
84
{

Freeserf.Core/Building.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public void SetUnderAttack()
387387
state.Progress |= (word)Misc.BitU(0);
388388
}
389389

390-
public bool IsUnderAttack =>Misc.BitTest(state.Progress, 0);
390+
public bool IsUnderAttack => Misc.BitTest(state.Progress, 0);
391391

392392
/// <summary>
393393
/// The threat level of the building. Higher values mean that
@@ -502,7 +502,7 @@ public bool BurnUp()
502502
{
503503
serf.CastleDeleted(Position, true);
504504
}
505-
505+
506506
// TODO: player defeated? mission outro etc?
507507
}
508508

@@ -719,7 +719,7 @@ public Serf CallDefenderOut()
719719
{
720720
// Remove knight from stats of defending building
721721
if (HasInventory())
722-
{
722+
{
723723
// Castle
724724
Game.GetPlayer(Player).DecreaseCastleKnights();
725725
}
@@ -925,7 +925,7 @@ public bool RequestedResourceDelivered(Resource.Type resource)
925925
if (state.Stock[i].Type == resource)
926926
{
927927
if (state.Stock[i].Requested == 0)
928-
{
928+
{
929929
if (Game.GetPlayer(Player).EmergencyProgramActive && !IsDone)
930930
{
931931
// In emergency program we set the requested amount to zero for most buildings.
@@ -946,7 +946,7 @@ public bool RequestedResourceDelivered(Resource.Type resource)
946946
++state.Stock[i].Available;
947947
--state.Stock[i].Requested;
948948
return true; // Resource delivered successfully
949-
}
949+
}
950950
}
951951
}
952952

@@ -1672,7 +1672,7 @@ void Update()
16721672
}
16731673
}
16741674
else
1675-
{
1675+
{
16761676
// Unfinished
16771677
switch (BuildingType)
16781678
{
@@ -2095,7 +2095,7 @@ public Request(Serf.Type serfType, Resource.Type resourceType1, Resource.Type re
20952095
public Resource.Type ResourceType2;
20962096
}
20972097

2098-
internal static readonly Request[] Requests = new Request[]
2098+
internal static readonly Request[] Requests = new Request[]
20992099
{
21002100
new Request(Serf.Type.None , Resource.Type.None , Resource.Type.None ),
21012101
new Request(Serf.Type.Fisher , Resource.Type.Rod , Resource.Type.None ),

Freeserf.Core/CommandLine.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
* along with freeserf.net. If not, see <http://www.gnu.org/licenses/>.
2121
*/
2222

23+
using Freeserf.Data;
2324
using System;
2425
using System.Collections.Generic;
25-
using Freeserf.Data;
2626

2727
namespace Freeserf
2828
{

Freeserf.Core/ConfigFile.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
namespace Freeserf
2929
{
30-
using Values = Dictionary<string, string>;
3130
using Sections = Dictionary<string, Dictionary<string, string>>;
31+
using Values = Dictionary<string, string>;
3232

3333
public class ConfigFile
3434
{

Freeserf.Core/Data/Buffer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ protected Buffer(uint capacity, Endianess endianess = Endianess.Default)
276276
}
277277

278278
owned = true;
279-
this.endianess = ChooseEndianess(endianess);
279+
this.endianess = ChooseEndianess(endianess);
280280
}
281281

282282
public Buffer(Endianess endianess = Endianess.Default)
@@ -408,7 +408,7 @@ public Buffer Pop(uint size)
408408
read += size;
409409

410410
return subBuffer;
411-
}
411+
}
412412

413413
public Buffer PopTail()
414414
{

Freeserf.Core/Data/DataSource.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public static Sprite CreateHalfMask(uint width, uint height, bool secondHalfFill
330330

331331
int halfSize = (int)width * (int)height * 2; // * 2 because 4 bytes per pixel and height * 4 / 2 = height * 2
332332

333-
int offset = secondHalfFilled ? halfSize : 0;
333+
int offset = secondHalfFilled ? halfSize : 0;
334334

335335
System.Buffer.BlockCopy(Enumerable.Repeat((byte)0xFF, halfSize).ToArray(), 0, sprite.data, offset, halfSize);
336336

@@ -576,7 +576,7 @@ unsafe public virtual void Blend(Sprite other)
576576
uint G = Blend(backG, frontG, alpha);
577577
uint B = Blend(backB, frontB, alpha);
578578

579-
*c++ = new Color { Blue = (byte)B, Green = (byte)G, Red = (byte)R, Alpha = 0xFF};
579+
*c++ = new Color { Blue = (byte)B, Green = (byte)G, Red = (byte)R, Alpha = 0xFF };
580580
++o;
581581
}
582582
}
@@ -592,7 +592,7 @@ unsafe public virtual void MakeAlphaMask()
592592
fixed (byte* pointer = data)
593593
{
594594
Color* c = (Color*)pointer;
595-
595+
596596
for (uint i = 0; i < width * height; ++i)
597597
{
598598
if (c->Alpha != 0x00)
@@ -618,7 +618,7 @@ unsafe public virtual void MakeAlphaMask()
618618
{
619619
c->Alpha = (byte)(c->Alpha - min);
620620
}
621-
621+
622622
++c;
623623
}
624624
}

Freeserf.Core/Data/DataSourceAmiga.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ private bool CheckFiles(params string[] dataFiles)
775775

776776
public override bool Check()
777777
{
778-
return CheckMusic() && CheckSound() && CheckGraphics();
778+
return CheckMusic() && CheckSound() && CheckGraphics();
779779
}
780780

781781
public override DataLoadResult Load()
@@ -953,7 +953,7 @@ public override Tuple<Sprite, Sprite> GetSpriteParts(Data.Resource resource, uin
953953
Buffer data = new Buffer(shadow);
954954
SpriteAmiga m = DecodeMaskSprite(data, 16, 6);
955955

956-
m.FillMasked(new Sprite.Color { Blue = 0x00, Green = 0x00, Red = 0x00, Alpha = 0x80});
956+
m.FillMasked(new Sprite.Color { Blue = 0x00, Green = 0x00, Red = 0x00, Alpha = 0x80 });
957957
m.SetDelta(2, 0);
958958
m.SetOffset(-2, -7);
959959

@@ -1012,7 +1012,7 @@ public override Tuple<Sprite, Sprite> GetSpriteParts(Data.Resource resource, uin
10121012
if (index == 32u)
10131013
{
10141014
s = new SpriteAmiga(32, 21);
1015-
var c = new Sprite.Color{ Blue = 0xBB, Green = 0x00, Red = 0x00, Alpha = 0xFF };
1015+
var c = new Sprite.Color { Blue = 0xBB, Green = 0x00, Red = 0x00, Alpha = 0xFF };
10161016
s.Fill(c);
10171017
}
10181018
else
@@ -1504,7 +1504,7 @@ unsafe Sprite GetGroundMaskSprite(uint index)
15041504

15051505
ushort height = data.Pop<ushort>();
15061506

1507-
SpriteAmiga sprite = new SpriteAmiga(32, height);
1507+
SpriteAmiga sprite = new SpriteAmiga(32, height);
15081508
sprite.SetDelta(2, 0);
15091509
sprite.SetOffset(0, 0);
15101510

@@ -1757,7 +1757,7 @@ Sprite GetMapObjectShadow(uint index)
17571757
uint shadowWidth = (uint)shadow.Pop<byte>() * 8;
17581758

17591759
SpriteAmiga sprite = DecodeMaskSprite(shadow, shadowWidth, shadowHeight);
1760-
sprite.FillMasked(new Sprite.Color{ Blue = 0x00, Green = 0x00, Red = 0x00, Alpha = 0x80});
1760+
sprite.FillMasked(new Sprite.Color { Blue = 0x00, Green = 0x00, Red = 0x00, Alpha = 0x80 });
17611761
sprite.Clear();
17621762
sprite.SetDelta(0, 0);
17631763
sprite.SetOffset(shadowOffsetX * 8, -shadowOffsetY);
@@ -2018,7 +2018,7 @@ SpriteAmiga MakeShadowFromSymbol(SpriteAmiga symbol)
20182018
res.Stick(symbol, 0, 1);
20192019
res.Stick(symbol, 2, 1);
20202020
res.Stick(symbol, 1, 2);
2021-
res.FillMasked(new Sprite.Color { Blue = 0xFF, Green = 0xFF, Red = 0xFF, Alpha = 0xFF});
2021+
res.FillMasked(new Sprite.Color { Blue = 0xFF, Green = 0xFF, Red = 0xFF, Alpha = 0xFF });
20222022

20232023
return res;
20242024
}

Freeserf.Core/Data/DataSourceDos.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ public override Tuple<Sprite, Sprite> GetSpriteParts(Data.Resource resource, uin
469469
else if (resource == Data.Resource.MapObject)
470470
{
471471
if ((index >= 128) && (index <= 143))
472-
{
472+
{
473473
// Flag sprites
474474
uint flagFrame = (index - 128) % 4;
475475
data = GetObject(dosRes.Index + 128 + flagFrame);

Freeserf.Core/Data/DataSourceMixed.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42

53
namespace Freeserf.Data
64
{

0 commit comments

Comments
 (0)