bool AddName(Object object, const char * name)
{
- bool result;
+ bool result = false;
if(this)
{
char * newName = CopyString(name);
while(true)
{
int nIndices = 0;
- PrimitiveGroupType type;
+ PrimitiveGroupType type = (PrimitiveGroupType)-1;
Material material = null;
bool foundGroup = false;
private:
Object()
{
- children.offset = (uint)&((Object)0).prev;
+ children.offset = (uint)(uintptr)&((Object)0).prev;
transform.scaling = { 1, 1, 1 };
transform.orientation = { 1,0,0,0 };
flags.transform = true;
case FRM_MESHINFO:
{
ObjectInfoBlock block { };
- Object object;
+ Object object = null;
ReadChunks(ReadFrameInfoBlock, info, &block);
}
delete block.dummyName;
}
- object.parent = info->rootObject;
+ if(object)
+ object.parent = info->rootObject;
}
else
object = info->rootObject.Find(block.name);
case FRM_CAMERA:
{
ObjectInfoBlock block { };
- Object object;
+ Object object = null;
ReadChunks(ReadFrameInfoBlock, info, &block);
}
delete block.dummyName;
}
- object.parent = info->rootObject;
+ if(object)
+ object.parent = info->rootObject;
}
else
object = info->rootObject.Find(block.name);
case FRM_CAMERATARGET:
{
ObjectInfoBlock block { };
- Object object;
+ Object object = null;
char targetName[MAXNAMELEN];
ReadChunks(ReadFrameInfoBlock, info, &block);
}
delete block.dummyName;
}
- object.parent = info->rootObject;
+ if(object)
+ object.parent = info->rootObject;
}
else
object = info->rootObject.Find(targetName);
case FRM_SPOTLIGHT:
{
ObjectInfoBlock block { };
- Object object;
+ Object object = null;
ReadChunks(ReadFrameInfoBlock, info, &block);
}
delete block.dummyName;
}
- object.parent = info->rootObject;
+ if(object)
+ object.parent = info->rootObject;
}
else
object = info->rootObject.Find(block.name);
case FRM_SPOTLIGHTTARGET:
{
ObjectInfoBlock block { };
- Object object;
+ Object object = null;
char targetName[MAXNAMELEN];
ReadChunks(ReadFrameInfoBlock, info, &block);
}
delete block.dummyName;
}
- object.parent = info->rootObject;
+ if(object)
+ object.parent = info->rootObject;
}
else
object = info->rootObject.Find(targetName);
public ColorAlpha * LoadPalette(const char * fileName, const char * type)
{
char ext[MAX_EXTENSION];
- subclass(BitmapFormat) format;
+ subclass(BitmapFormat) format = null;
ColorAlpha * palette = null;
int typeToTry = -1;
Bitmap bitmap { };
{
bool result = false;
char ext[MAX_EXTENSION];
- subclass(BitmapFormat) format;
+ subclass(BitmapFormat) format = null;
int typeToTry = -1;
const char * guessedType = type;
bool Save(const char * fileName, const char * type, void * options)
{
char ext[MAX_EXTENSION];
- subclass(BitmapFormat) format;
+ subclass(BitmapFormat) format = null;
if(!type)
type = strlwr(GetExtension(fileName, ext));
int c;
for(c = 0; c < w; c++, dest++)
{
- Color destColor;
+ Color destColor = 0;
if(pixelFormat == pixelFormat565) { destColor = (Color)*(Color565 *)dest; }
else if(pixelFormat == pixelFormat555) { destColor = (Color)*(Color555 *)dest; }
else if(pixelFormat == pixelFormat444) { destColor = (Color)*(Color444 *)dest; }
int c, nb, glyphIndex = 0;
unichar lastPack = 0;
GlyphPack pack = font.asciiPack;
- int wc;
- uint * glyphs;
+ int wc = 0;
+ uint * glyphs = null;
int numGlyphs = 0;
bool rightToLeft = false;
int fontEntryNum = 0;
for(c = 0; c < len || (numGlyphs && (rightToLeft ? (glyphIndex >= 0) : (glyphIndex < numGlyphs)));)
{
- uint glyphNo;
+ uint glyphNo = 0;
uint packNo;
if(numGlyphs && (rightToLeft ? (glyphIndex >= 0) : (glyphIndex < numGlyphs)))
{
bool gotAlphaMonth = false;
DateTime time;
int year, day;
- Month month;
+ Month month = 0;
int numerics[3];
int len[3];
int count = 0;
{
case stringList:
{
- Container<String> list = value;
+ Container<String> list = (void *)value;
Iterator<String> item { list };
item.Next();
while(item.pointer)
int c;
bool foundDayOfTheWeek = false;
bool foundDate = false;
- DayOfTheWeek dayOfTheWeek;
+ DayOfTheWeek dayOfTheWeek = 0;
int day = 0;
int minute = 0;
int second = 0;
BitMember bitMember = (BitMember) member;
if(subDataType)
{
- DataValue value = { 0 };
+ DataValue value { 0 };
value.ui = ((uint (*)(void *))(void *)prop.Get)(object);
value.ui &= ~ (uint)bitMember.mask;
value.ui |= *(uint32 *)setValue << bitMember.pos;
bool result = false;
void * dataPtr, * data = null, * subData = null;
void * propObject = null;
- DataValue valueData = { 0 }, valueSubData = { 0 };
+ DataValue valueData { 0 };
+ DataValue valueSubData { 0 };
uint bitValue;
if(!mainDataType)
Copyright (c) 2001 Jerome Jacovella-St-Louis
All Rights Reserved.
-
+
chess.ec - Chess Main Window
****************************************************************************/
#ifdef ECERE_STATIC
MenuItem * driverItems;
ChessState chessState;
-
+
StatusField stateField { statusBar, width = stateWidth};
StatusField turnField { statusBar, width = turnWidth };
AIThread aiThread { chess = this };
// Windows
-
+
ListBox moveList
{
parent = this,
text = "2D Chess Board",
chessState = &chessState
};
-
+
Chess3D chess3D
{
parent = this,
chessState.isLocalPlayer[Black] = false;
EnableMenus();
-
+
RandomSeed((int)(GetTime() * 10000));
-
+
NewGame();
}
return true;
// Help Menu
MenuItem aboutItem
- {
+ {
helpMenu, "About...\tF1", a, f1;
bool NotifySelect(MenuItem selection, Modifiers mods)
{
return true;
}
};
-
+
// --- Chess Utilities ---
bool MakeMove(int x1, int y1, int x2, int y2, PieceType promotion)
{
bool valid = false;
-
+
PieceType type = chessState.board[y1][x1].type;
Player player = chessState.board[y1][x1].player;
promotion = (PieceType)Promotion { master = this }.Modal();
}
}
-
+
if(StateMakeMove(chessState, x1,y1,x2,y2, promotion, true, null))
{
valid = true;
-
+
if(chessState.isLocalPlayer[player] && !local && !ai)
{
ChessPacket packet
- {
+ {
type = Position,
player = player,
x1 = (byte)x1,
GenerateMoveList(chessState, stack);
delete stack.moves;
-
+
if(Check(chessState, chessState.turn, -1, -1))
{
if(stack.count)
turnField.text = "";
}
}
-
+
chess2D.Update(null);
chess3D.Update(null);
- return valid;
+ return valid;
}
void ProcessUserMove(int x1, int y1, int x2, int y2)
#endif
chessState.turn = White;
- chessState.castled[White] =
+ chessState.castled[White] =
chessState.castled[Black] = false;
// EN PASSANT STATUS
MakeMoveChar('f',7, 'h',8);
// 14
MakeMoveChar('d',1, 'd',2);
- MakeMoveChar('e',7, 'e',6);
+ MakeMoveChar('e',7, 'e',6);
*/
}
{
MakeMove(x1 - 'a', y1 - 1, x2 - 'a', y2 - 1, Queen);
}
-
+
void EnableMenus()
{
stopItem.disabled = !hosting;
{
driverItems[c] = MenuItem { viewMenu, app.drivers[c], NotifySelect = SetDisplayDriver };
driverItems[c].id = c;
- driverItems[c].isRadio = true;
+ driverItems[c].isRadio = true;
}
// this.SetPalette(palette, true);
bool EndGame()
{
- if(chessState.gameRunning &&
+ if(chessState.gameRunning &&
(chessState.state == Normal || chessState.state == Check))
{
- if(MessageBox { type = okCancel, contents = "Quit current game?",
+ if(MessageBox { type = okCancel, contents = "Quit current game?",
master = this, text = "ECERE Chess" }.Modal() == cancel)
- return false;
+ return false;
}
if(sockets[SERVER_COLOR])
sockets[SERVER_COLOR].Disconnect(0);
delete sockets[White];
delete driverItems;
}
-
- void Connect(char * address)
+
+ void Connect(const char * address)
{
ChessSocket socket { chess = this };
if(socket.Connect(address, CHESS_PORT))
chess.chess2D.Update(null);
chess.chess3D.Update(null);
}
-
+
uint OnReceive(const byte * buffer, uint count)
{
if(count >= sizeof(ChessPacket))
{
Chess chess;
property Chess chess { set { chess = value; } }
-
+
void OnAccept()
{
if(!chess.chessState->gameRunning)
define BOARD_WIDTH = SQUARE_W * 8;
define BOARD_HEIGHT = SQUARE_H * 8;
-static char * names[12] =
+static const char * names[12] =
{
"whitePawn", "whiteKnight", "whiteBishop", "whiteRook", "whiteQueen", "whiteKing",
"blackPawn", "blackKnight", "blackBishop", "blackRook", "blackQueen", "blackKing"
import "chess.ec"
-static char * names[Player][PieceType] =
+static const char * names[Player][PieceType] =
{
{ "", "WhitePawn", "WhiteKnigh", "WhiteBisho", "WhiteRook", "WhiteQueen", "WhiteKing" },
{ "", "BlackPawn", "BlackKnigh", "BlackBisho", "BlackRook", "BlackQueen", "BlackKing" }
if(type)
{
- char * name = names[player][type];
+ const char * name = names[player][type];
Object object = chessSet.Find(name);
if(object)
{
PieceType overType = overAtBoard.type;
if(overType)
{
- char * name = names[overPlayer][overType];
+ const char * name = names[overPlayer][overType];
Object over = chessSet.Find(name);
if(over)
height = over.max.y - over.min.y;
object.UpdateTransform();
- object.tag = (void *)(((y)*8)+(x)+1);
+ object.tag = (void *)(intptr)(((y)*8)+(x)+1);
display.DrawObject(object);
}
}
if(display.GetHits(list))
{
HitRecord hit = list.first;
- int tag = ((int)hit.tags[0]) - 1;
+ int tag = ((int)(intptr)hit.tags[0]) - 1;
int sx = tag & 7, sy = tag >> 3;
if(pieceSelected)