{
processAlone = true;
public:
- NetworkClientFile Open(char * fileName, FileOpenMode mode)
+ NetworkClientFile Open(const char * fileName, FileOpenMode mode)
{
NetworkClientFile f { };
Request request;
}
// Packet Sending Functions
- void SendOpenPacket(char * fileName)
+ void SendOpenPacket(const char * fileName)
{
int len = strlen(fileName);
OpenPacket packet = (OpenPacket) new0 byte[sizeof(class OpenPacket) + len];
public void OpenMixer()
{
- HMIXER mixerHandle;
WAVEFORMATEX waveFormat = { 0 };
waveFormat.nSamplesPerSec = 44100; //(cur_stream && cur_stream->audio_st && cur_stream->audio_st->codec) ? cur_stream->audio_st->codec->sample_rate : 44100;
waveFormat.wBitsPerSample = 16;
waveFormat.nAvgBytesPerSec = waveFormat.nBlockAlign * waveFormat.nSamplesPerSec;
waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL);
- mixerOpen((HMIXER *)&hmx, (uint)hWaveOut, 0, 0, MIXER_OBJECTF_HWAVEOUT);
+ mixerOpen((HMIXER *)&hmx, (uint)(uintptr)hWaveOut, 0, 0, MIXER_OBJECTF_HWAVEOUT);
}
public void CloseMixer()
result.size = dwNotifySize * NUM_PLAY_NOTIFICATIONS;
g_pSoundManager.InitStreaming(&streamingSound, NUM_PLAY_NOTIFICATIONS, dwNotifySize, dSoundThread.g_hNotificationEvent,
- wanted.callback, wanted.userdata, wanted.channels, wanted.freq, wanted.bits);
+ (void *)wanted.callback, wanted.userdata, wanted.channels, wanted.freq, wanted.bits);
if(streamingSound)
{
streamingSound.volume = wanted.volume;
static bool PlayBuffer( bool bLooped )
{
- void * pDSB;
+ //void * pDSB;
if(!streamingSound)
return false;
if(streamingSound.Reset())
return false;
- pDSB = streamingSound.GetBuffer( 0 );
+ //pDSB = streamingSound.GetBuffer( 0 );
SetEvent(dSoundThread.g_hNotificationEvent);
return true;
int RestoreBuffer( IDirectSoundBuffer * pDSB, bool* pbWasRestored )
{
int hr;
- uint dwStatus;
+ DWORD dwStatus;
if( pDSB == null )
return CO_E_NOTINITIALIZED;
{
if( apDSBuffer[i] )
{
- uint dwStatus = 0;
+ DWORD dwStatus = 0;
IDirectSoundBuffer_GetStatus(apDSBuffer[i], &dwStatus );
if ( ( dwStatus & DSBSTATUS_PLAYING ) == 0 )
break;
return result;
}
+ /*
int Stop()
{
int hr = 0;
return hr;
}
+ */
bool HandleWaveStreamNotification( )
{
- uint dwCurrentPlayPos;
- uint dwPlayDelta;
- uint dwBytesWrittenToBuffer;
+ DWORD dwCurrentPlayPos;
void * pDSLockedBuffer = null;
void * pDSLockedBuffer2 = null;
- uint dwDSLockedBufferSize;
- uint dwDSLockedBufferSize2;
+ DWORD dwDSLockedBufferSize;
+ DWORD dwDSLockedBufferSize2;
uint playCursor, writeCursor;
- bool bRestored;
uint start, size;
-
- static uint cursor;
bool written = true;
int c;
+
while(written)
{
written = false;
int Reset()
{
- int hr;
bool bRestored;
int result;
int FillBufferWithSound( IDirectSoundBuffer * pDSB, bool bRepeatWavIfBufferLarger )
{
- int hr;
- void* pDSLockedBuffer = null; // Pointer to locked buffer memory
- uint dwDSLockedBufferSize = 0; // Size of the locked DirectSound buffer
- uint dwWavDataRead = 0; // Amount of data read from the wav file
+ void * pDSLockedBuffer = null; // Pointer to locked buffer memory
+ DWORD dwDSLockedBufferSize = 0; // Size of the locked DirectSound buffer
if( pDSB == null )
return CO_E_NOTINITIALIZED;
callback(data, pDSLockedBuffer, dwDSLockedBufferSize);
- dwWavDataRead = dwDSLockedBufferSize;
-
- printf("Filling 16 spots\n");
+ // printf("Filling 16 spots\n");
IDirectSoundBuffer_Unlock(pDSB, pDSLockedBuffer, dwDSLockedBufferSize, null, 0 );
//dwNextWriteOffset = dwNotifySize*2;
bool InitStreaming(StreamingSound * ppStreamingSound, uint dwNotifyCount, uint dwNotifySize, void * hNotifyEvent,
void (*callback)(void * data, void * buffer, int len), void * data, int nChannels, int freq,int bits)
{
- int hr;
IDirectSoundBuffer * pDSBuffer = null;
uint dwDSBufferSize = 0;
DSBPOSITIONNOTIFY * aPosNotify = null;
struct WAVEHDR
{
- byte format[4] __attribute__((packed));
+ byte format[4];
uint32 f_len __attribute__((packed));
- byte wave_fmt[8] __attribute__((packed));
+ byte wave_fmt[8];
uint32 fmt_len __attribute__((packed));
uint16 fmt_tag __attribute__((packed));
uint16 channel __attribute__((packed));
uint32 avg_bytes_per_sec __attribute__((packed));
uint16 blk_align __attribute__((packed));
uint16 bits_per_sample __attribute__((packed));
- byte data[4] __attribute__((packed));
+ byte data[4];
uint32 data_len __attribute__((packed));
};
public class Sound
{
public:
- property String fileName { set { Load(value); } }
+ property const String fileName { set { Load(value); } }
int frequency, bits, channels, length;
byte * data;
~Sound() { delete data; }
- bool Load(char * fileName)
+ bool Load(const char * fileName)
{
bool result = false;
WAVEHDR header;
int chn = sound.channels;
if(sound.bits == 16)
{
- short * sBuffer = sound.data;
+ short * sBuffer = (short *)sound.data;
int se = 0;
int s = v.pos;
short sampleL = sBuffer[s];
{
timer.Stop();
if(!(animation.Load(value)))
- Logf("Couldn't load animation %s.\n", value);
+ {
+ String s = PrintString("Couldn't load animation ", value, ".");
+ MessageBox { caption = "Ecere FLC Player", contents = s }.Modal();
+ Destroy(0);
+ delete s;
+ }
else
{
image.Allocate(null, animation.width, animation.height, 0, pixelFormat8, true);
animation.PlayFrame(image);
timer.delay = animation.speed;
timer.Start();
-
}
}
readOnly = true;
noCaret = true;
};
- property char * sourceFile
+ property const char * sourceFile
{
set
{
html.block.ClearEntries();
}
- property char * location
+ property const char * location
{
set
{
AStar * AStarInitialize(int width, int height, int stackSize)
{
- AStar * result = null;
AStar * aStar = new0 AStar[1];
if(aStar)
{
return result;
}
-bool SequenceLoadTable(Sequence **sequences, int count, char *fileName)
+bool SequenceLoadTable(Sequence **sequences, int count, const char * fileName)
{
bool result = false;
File f = FileOpen(fileName, read);
}
}
- bool Load(char *bmpname, char *sizefile, bool trans, bool usePaletteShades, ColorAlpha * palette, DisplaySystem displaySystem)
+ bool Load(const char *bmpname, const char *sizefile, bool trans, bool usePaletteShades, ColorAlpha * palette, DisplaySystem displaySystem)
{
bool result = false;
File f = FileOpen(sizefile, read);
Bitmap bmpFrames {};
if(bmpFrames.Load(bmpname, null, null))
{
- f.Getc(&numFrames);
+ f.Getc((char *)&numFrames);
f.Read(&maxWidth, sizeof(uint16),1);
f.Read(&maxHeight, sizeof(uint16),1);
frames = new0 SpriteFrame[numFrames];
for(c=0; c<numFrames; c++)
{
byte width,height;
- f.Getc(&width);
- f.Getc(&height);
- f.Getc(&frames[c].xDis);
- f.Getc(&frames[c].yDis);
+ f.Getc((char *)&width);
+ f.Getc((char *)&height);
+ f.Getc((char *)&frames[c].xDis);
+ f.Getc((char *)&frames[c].yDis);
frames[c].bitmap = Bitmap {};
if(frames[c].bitmap.Allocate(null, width,height,0,bmpFrames.pixelFormat, false))
return West;
else if((xd<0)&&(yd<0))
return NorthWest;
+ return North;
}
static void MapForward(Direction direction, Point result, uint16 distance)
}
bool OnLoadGraphics()
{
- char * hiragana[6] = { "あ", "い", "う", "え", "お", "ん" };
+ const char * hiragana[6] = { "あ", "い", "う", "え", "お", "ん" };
int c;
PrimitiveGroup group;
if(argc > 1)
{
selected = true;
- strcpy(fileDialog.filePath, argv[1]);
+ fileDialog.filePath = argv[1];
}
else
{
- strcpy(fileDialog.filePath, "models/cow/cow.3DS");
+ fileDialog.filePath = "models/cow/cow.3DS";
//selected = true;
}
while(selected || fileDialog.Modal() == ok)
FillModeValue fillMode;
SkyBox sky { size = { 10000, 10000, 10000 }, folder = ":skycube", extension = "jpg" };
- char * modelFile;
+ const char * modelFile;
ModelViewer()
{
Resolution resolution;
PixelFormat colorDepth;
int refreshRate;
- char * driver;
+ const char * driver;
driver = "OpenGL";
Picture ecereLogo { this, image = BitmapResource { ":ecere.png", alphaBlend = true }, anchor = { left = 30, top = 10 } };
class Hello3D : Window
{
- text = "Hello, 3D";
+ caption = "Hello, 3D";
background = black;
borderStyle = sizable;
hasMaximize = true;
Euler offset;
};
-static char * iconFiles[] =
+static const char * iconFiles[] =
{
":icon1.png",
":icon2.png",
bool OnKeyHit(Key key, unichar character)
{
static int id = 0;
- static char * shotFileNames[] =
+ static const char * shotFileNames[] =
{
":img1.jpg", ":img2.jpg", ":img3.jpg", ":img4.jpg", ":img5.jpg"
};
if(poppingWindow) break;
if(sliding == 1.0 && !dockHidden)
{
- Quaternion fa, ta;
- Vector3D fp, tp;
-
Window window = virtualDesktop.activeChild;
if(window)
{
Window3D window3D = Desktop3DGetWindowHandle(window);
camera.Update();
- fa = fromAngle = camera.cOrientation;
- fp = fromPosition = camera.cPosition;
+ fromAngle = camera.cOrientation;
+ fromPosition = camera.cPosition;
camera.type = lookAt;
camera.position = { 0,0,0 };
dockHidden = true;
camera.Update();
- tp = toPosition = camera.cPosition;
- ta = toAngle = camera.cOrientation;
+ toPosition = camera.cPosition;
+ toAngle = camera.cOrientation;
camera.AdjustAngle(fromAngle);
camera.AdjustPosition(fromPosition);
int w = box.right - box.left + 1;
int h = box.bottom - box.top + 1;
- glBindTexture(GL_TEXTURE_2D, (int)window3D.bitmap.driverData);
+ glBindTexture(GL_TEXTURE_2D, (int)(intptr)window3D.bitmap.driverData);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
for(y = start; y <= end && !view3D.abort; y++)
{
- Box box { 0, y, bitmap.width, y };
-
for(x = 0; x < bitmap.width && !view3D.abort; x++)
{
Vector3D v, end;
{
int c;
bool visible = true;
- int sign = 0;
planes[plane].IntersectLine(ray, intersect);
for(c = 0; c < 6; c++)
{
void Compute()
{
- Quaternion q;
bulb.size = size;
bulb.power = power;
RTCube::Compute();
double t = 0;
int refine = 0;
double refineDT = dt;
+ double refineDT10 = refineDT * 10;
double stopT = MAXDOUBLE;
bool firstPointInside = false;
+ Vector3D halfSize = { size.x / 2, size.y / 2, size.z / 2 };
if(backwards && bulb.IsPointInside(l.p0, iters))
{
firstPointInside = true;
l.p0.y - l.delta.y * t,
l.p0.z - l.delta.z * t
};
- if(p.x + refineDT*10 < -size.x / 2 || p.x - refineDT*10 > size.x / 2 ||
- p.y + refineDT*10 < -size.y / 2 || p.y - refineDT*10 > size.y / 2 ||
- p.z + refineDT*10 < -size.z / 2 || p.z - refineDT*10 > size.z / 2)
+ if(p.x + refineDT10 < -halfSize.x || p.x - refineDT10 > halfSize.x ||
+ p.y + refineDT10 < -halfSize.y || p.y - refineDT10 > halfSize.y ||
+ p.z + refineDT10 < -halfSize.z || p.z - refineDT10 > halfSize.z)
{
- Print("");
+ // Print("");
break;
}
stopT = t;
t -= refineDT;
refineDT /= 2;
+ refineDT10 = refineDT * 10;
}
if(t > stopT)
{
double d2 = (found[1] && found[2]) ? (distances[1] * distances[2]) : MAXDOUBLE;
double d3 = (found[2] && found[3]) ? (distances[2] * distances[3]) : MAXDOUBLE;
double d4 = (found[3] && found[0]) ? (distances[3] * distances[0]) : MAXDOUBLE;
- if(d1 < minDistance || d1 < d2 && d1 < d3 && d1 < d4)
+ if(d1 < minDistance || (d1 < d2 && d1 < d3 && d1 < d4))
{
normalPlane.FromPoints(points[1], p, points[0]);
normal.Add(normal, normalPlane.normal);
count++;
}
- if(d2 < minDistance || d2 < d1 && d2 < d3 && d2 < d4)
+ if(d2 < minDistance || (d2 < d1 && d2 < d3 && d2 < d4))
{
normalPlane.FromPoints(points[2], p, points[1]);
normal.Add(normal, normalPlane.normal);
count++;
}
- if(d1 < minDistance || d3 < d1 && d3 < d2 && d3 < d4)
+ if(d1 < minDistance || (d3 < d1 && d3 < d2 && d3 < d4))
{
normalPlane.FromPoints(points[3], p, points[2]);
normal.Add(normal, normalPlane.normal);
count++;
}
- if(d4 < minDistance || d4 < d1 && d4 < d2 && d4 < d2)
+ if(d4 < minDistance || (d4 < d1 && d4 < d2 && d4 < d2))
{
normalPlane.FromPoints(points[0], p, points[3]);
normal.Add(normal, normalPlane.normal);
// OutputTexture("res/texture.png");
- if(terrain.Create(heightMap, 16, 1025, 2, resLon, RESOLUTION_LAT, 512,512))
+ if(terrain.Create(heightMap, 16, 1025, 2, resLon, (float)RESOLUTION_LAT, 512,512))
result = true;
delete f;
}
int i;
for(i = 0; i < map.count; i++)
{
- int num = map[i] = GetRandom(0, 7);
+ map[i] = GetRandom(0, 7);
elv[i] = GetRandom(1, 100);
}
}
{
Bitmap textureFile { };
int i, x, y;
- PrimitiveGroup group;
cowModel.Load(":cow.3DS", null, displaySystem);
cowModel.Merge(displaySystem);
{
int ix = y * width + x;
int num = map[ix];
- int xs = -((tileSize+gap) * width) / 2;
- int ys = -((tileSize+gap) * height) / 2;
float h = elv[ix];
Cube cube { };
class Form1 : Window
{
- text = "Form1";
+ caption = "Form1";
background = activeBorder;
borderStyle = sizable;
hasMaximize = true;
Button button1
{
- this, text = "Play", position = { 200, 168 };
+ this, caption = "Play", position = { 200, 168 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
import "EcereAudio"
static uint16 periods[] = { 1712, 1616, 1524, 1440, 1356, 1280, 1208, 1140, 1076, 1016, 960, 907};
-static String notes[12] = { "C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"};
+static const String notes[12] = { "C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"};
struct S3MHeader
{
Array<Pattern> patterns { };
Voice voices[32];
- bool Load(char *fileName)
+ bool Load(const char *fileName)
{
int i,p,c;
byte what, row, channel;
SND_SetVolume(volume, channel);
SND_Play(ins.sound, channel);
*/
- int c2spd = ins.header.c2spd;
+ //int c2spd = ins.header.c2spd;
//double freq = pow(Do_, note) * pow(2, octave-4) / (c2spd/8363.0);
double freq = 14317456.0 / note_st3period / 22150/2;
//double freq = 500.0/note_st3period;
bool Play(Mixer mixer)
{
bool result = false;
- int initSpeed = header.initSpeed;
+ // int initSpeed = header.initSpeed;
Time time = /*pattern == 10*/ 1? speed/(1.1*45.5) : 0;
Time current = GetTime();
FormConcentrations formConcentrations = row.formConcentrations;
// if(commercialNames.OnCompare(*(void **)boxCommercialNames.data))
- if(class(StringList)._vTbl[__ecereVMethodID_class_OnCompare](class(StringList), commercialNames, *(void **)boxCommercialNames.data))
+
+ if(((int (*)(Class, StringList, StringList))class(StringList)._vTbl[__ecereVMethodID_class_OnCompare])(class(StringList), commercialNames, *(void **)boxCommercialNames.data))
boxCommercialNames.foreground = red;
// if(genericName.OnCompare(*(void **)boxGenericName.data))
- if(class(String)._vTbl[__ecereVMethodID_class_OnCompare](class(String), genericName, *(void **)boxGenericName.data))
+ if(((int (*)(Class, const String, const String))class(String)._vTbl[__ecereVMethodID_class_OnCompare])(class(String), genericName, *(void **)boxGenericName.data))
boxGenericName.foreground = red;
if(drugClass.OnCompare(boxClass.data))
}
else
{
- class(double)._vTbl[__ecereVMethodID_class_OnGetString](class(double), &amount, amountString, null, null);
+ ((const char * (*)(Class, double *, char *, void *, bool *)) class(double)._vTbl[__ecereVMethodID_class_OnGetString])(class(double), &amount, amountString, null, null);
if(form)
{
String formName = form.name;
inputString.Deselect();
inputString.AddS(button.text);
inputString.Update(null);
+ return true;
}
Label statusLabel { this, size = { 274, 21 }, position = { 250, 45 } };
Button ebutton { this, text = constant_string[e], NotifyClicked = TypeButton, size = { 20, 20 }, position = { 170, 45 } };
}
//Note that FromString likes to toy with the string, but anything done to the string will be undone.
- bool FromString(char *str, CASDictionary dictionary) {
+ bool FromString(const char *str, CASDictionary dictionary) {
ExpressionFromString(this, str, dictionary);
return Sanitize(this, dictionary);
}
- char *ToString(void) {
-
- }
const char *OpString(void) {
if (type==prefix && prefix.op<PrefixOperator::enumSize)
return prefix_op_string[prefix.op];
Expression op {type=binary};
Expression w;
ExpressionClass pc;
- int order;
if (s[1]==0) { //single-character operator
switch (*s) {
case '+':
}
};
-void ExpressionFromString(Expression expr, char *str, CASDictionary dictionary) {
+void ExpressionFromString(Expression expr, const char *str, CASDictionary dictionary) {
ExpressionTree tree {dictionary};
- char *s, *p, *e; //token start and end
+ const char * s; //token start and end
+ char *p, *e;
CASCharFlag flag;
CASCharFlags cf = cascharflags;
char borrow;
expr.Free();
s = str;
- e = s;
+ e = (char *)s;
while (*s) {
for (;;) //for loop is used so multiple character types that merge into one token can be implemented in the future
{ //grab the next token
flag = (CASCharFlag)f;
break;
}
- p = s;
+ p = (char *)s;
switch (flag) {
case letter: {
uint f;
if (f != (uint)-1)
tree.PushFunction((CASFunction)f);
else do {
- unsigned char c;
uint con = (uint)-1;
UTF8GetChar(p, &charlen);
p += charlen;
}
};
-char *findfirst(const char *haystack, uint haystacklen, CharFlags cf) {
+const char *findfirst(const char *haystack, uint haystacklen, CharFlags cf) {
const byte *h = (const byte*)haystack;
while (haystacklen--) {
if (cf.flags[(uint)*h++])
- return h-1;
+ return (const char *)h-1;
}
return null;
}
-char *findfirstnon(const char *haystack, uint haystacklen, CharFlags cf) {
+const char *findfirstnon(const char *haystack, uint haystacklen, CharFlags cf) {
const byte *h = (const byte*)haystack;
while (haystacklen--) {
if (!cf.flags[(uint)*h++])
- return h-1;
+ return (const char *)h-1;
}
return null;
}
-char *findlast(const char *haystack, uint haystacklen, CharFlags cf) {
+const char *findlast(const char *haystack, uint haystacklen, CharFlags cf) {
const byte *h = (const byte*)haystack + haystacklen;
while (haystacklen--) {
if (cf.flags[(uint)*--h])
- return h;
+ return (const char *)h;
}
return null;
}
-char *findlastnon(const char *haystack, uint haystacklen, CharFlags cf) {
+const char *findlastnon(const char *haystack, uint haystacklen, CharFlags cf) {
const byte *h = (const byte*)haystack + haystacklen;
while (haystacklen--) {
if (!cf.flags[(uint)*--h])
- return h;
+ return (const char *)h;
}
return null;
}
{ POOR, true, false, 1, HIDE }
};
-char * behaviors[4] = { "Run", "Hide", "Wander", "Attack" };
+const char * behaviors[4] = { "Run", "Hide", "Wander", "Attack" };
#define NUM_EXAMPLES (sizeof(examples) / sizeof(Example))
for(h = 0; h<NUM_HIDDEN; h++)
{
Neuron * hidden = &hiddenNeurons[h];
- Synapse * synapse = &input->axons._[h];
+ Synapse * synapse = &input->axons[h];
if(!hidden->dendrons.size)
hidden->dendrons.size = NUM_INPUT;
- hidden->dendrons._[i] = synapse;
+ hidden->dendrons[i].ptr = synapse;
synapse->dendron = input;
synapse->axon = hidden;
for(o = 0; o<NUM_OUTPUT; o++)
{
Neuron * output = &outputNeurons[o];
- Synapse * synapse = &hidden->axons._[o];
+ Synapse * synapse = &hidden->axons[o];
if(!output->dendrons.size)
output->dendrons.size = NUM_HIDDEN;
- output->dendrons._[h] = synapse;
+ output->dendrons[h].ptr = synapse;
synapse->dendron = hidden;
synapse->axon = output;
TAUGHT
};
-static struct SynapsePtr
+struct SynapsePtr
{
- Synapse * a;
+ Synapse * ptr; // TOFIX: Support pointers in generic types
};
-class ArraySynapse : OldArray
-{
- type = class(Synapse);
- Synapse * _;
-};
-
-class ArraySynapsePtr : OldArray
-{
- type = class(SynapsePtr);
- Synapse ** _;
-}
-
static double Sigmoid(double x)
{
return 1 / (1 + exp(-x));
struct Neuron
{
double bias;
- ArraySynapse axons;
- ArraySynapsePtr dendrons;
+ Array<Synapse> axons;
+ Array<SynapsePtr> dendrons;
double activation;
double error;
NeuronState state;
void Init()
{
- axons = ArraySynapse { };
- dendrons = ArraySynapsePtr { };
+ axons = { };
+ dendrons = { };
}
void Unactivate()
int c;
for(c = 0; c<dendrons.size; c++)
{
- Synapse * synapse = dendrons._[c];
+ Synapse * synapse = dendrons[c].ptr;
if(synapse->dendron->state != CLEARED)
synapse->dendron->Unactivate();
}
activation = bias;
for(c = 0; c<dendrons.size; c++)
{
- Synapse * synapse = dendrons._[c];
+ Synapse * synapse = dendrons[c].ptr;
if(synapse->dendron->state != ACTIVATED)
synapse->dendron->Activate();
activation += synapse->dendron->activation * synapse->weight;
error = 0;
for(c = 0; c<axons.size; c++)
{
- Synapse * synapse = &axons._[c];
+ Synapse * synapse = &axons[c];
if(synapse->axon->state != PROPAGATED)
synapse->axon->BackPropagate();
error += synapse->axon->error * synapse->weight;
{
for(c = 0; c<dendrons.size; c++)
{
- Synapse * synapse = dendrons._[c];
+ Synapse * synapse = dendrons[c].ptr;
if(state != TAUGHT)
synapse->dendron->Teach(learnRate);
synapse->weight += learnRate * error * synapse->dendron->activation;
for(y=0; y<DIMY; y++)
for(x=0; x<DIMX; x++)
- surface.Blit(gfx[board[y][x]],
+ surface.Blit(gfx[(int)board[y][x]],
offX + x*mapSize.w, offY + y*mapSize.h, 0,0,
mapSize.w,mapSize.h);
surface.Blit(gfx[PLAYER],
if(key == enter)
{
int l;
- char * pwd = passEdit.contents;
+ const char * pwd = passEdit.contents;
for(l=1; l<=NUMLEVELS; l++)
if(!strcmpi(pwd,passwords[l]))
{
for(c=0; c<numDown; c++)
{
- poker.DrawCard(surface, c*GAP, 0, (human || gameOver && !folded) ? POKER_Card(down[c]) : -1);
+ poker.DrawCard(surface, c*GAP, 0, (human || (gameOver && !folded)) ? POKER_Card(down[c]) : -1);
}
POKER_HandType(bestHand);
for(c=0; c<numUp; c++)
import "widow.ec"
import "bet.ec"
-static String cardsNames[] =
+static const String cardsNames[] =
{
":ac.png", ":ad.png", ":ah.png", ":as.png", ":2c.png", ":2d.png", ":2h.png", ":2s.png", ":3c.png", ":3d.png", ":3h.png", ":3s.png",
":4c.png", ":4d.png", ":4h.png", ":4s.png", ":5c.png", ":5d.png", ":5h.png", ":5s.png", ":6c.png", ":6d.png", ":6h.png", ":6s.png",
enum TrumpFlag { AnyCard, NoTrump, PutTrump, Alone, DontNudify };
-static int Discard(Player player, char * numbers, TrumpFlag trumpFlag)
+static int Discard(Player player, const char * numbers, TrumpFlag trumpFlag)
{
RuffGame * game = player.game;
Round * round = &game->rounds[game->round];
Kind kind;
} Card;
-static String cardsNames[] =
+static const String cardsNames[] =
{
":ac.png", ":ad.png", ":ah.png", ":as.png", ":2c.png", ":2d.png", ":2h.png", ":2s.png", ":3c.png", ":3d.png", ":3h.png", ":3s.png",
":4c.png", ":4d.png", ":4h.png", ":4s.png", ":5c.png", ":5d.png", ":5h.png", ":5s.png", ":6c.png", ":6d.png", ":6h.png", ":6s.png",
}
}
-void Player_SetName(Player player, char * name)
+void Player_SetName(Player player, const char * name)
{
Ruff ruff = player.ruff;
if(player.socket)
}
// SERVER TO CLIENT : Informations
-void Player_InformPlayerInfo(Player player, PlayerPosition who, char *name)
+void Player_InformPlayerInfo(Player player, PlayerPosition who, const char *name)
{
Ruff ruff = player.ruff;
RuffGame * game = &ruff.game;
Player_RequestCard(player);
}
-void Server_SetName(RuffGame game, Player player, char * name)
+void Server_SetName(RuffGame game, Player player, const char * name)
{
int c;
strcpy(player.name, name);
class Trump : Kind
{
- char * OnGetString(char * string, void * fieldData, bool * needClass)
+ const char * OnGetString(char * string, void * fieldData, bool * needClass)
{
switch(this)
{
import "ecere"
-static String cardsNames[] =
+static const String cardsNames[] =
{
":ac.png", ":ad.png", ":ah.png", ":as.png", ":2c.png", ":2d.png", ":2h.png", ":2s.png", ":3c.png", ":3d.png", ":3h.png", ":3s.png",
":4c.png", ":4d.png", ":4h.png", ":4s.png", ":5c.png", ":5d.png", ":5h.png", ":5s.png", ":6c.png", ":6d.png", ":6h.png", ":6s.png",
bool ChowClicked(Button button, int x, int y, Modifiers mods)
{
- int i, j, suit, number;
+ int i, j;
int tempCtr = 0;
int tempHouse[13];
for(i=0;i<13;i++)
{
tempHouse[i]=0;
}
- suit = KIND(discard[discardCounter-1]);
- number = NUMBER(discard[discardCounter-1]);
tempHouse[tempCtr++] = discard[discardCounter-1];
for(i=0;i<player[currentPlayer].numCards;i++)
{
}
}
player[currentPlayer].numCards = j;
- discard[discardCounter--];
+ discardCounter--;
drawButton[currentPlayer].disabled = true;
chowButton[currentPlayer].disabled = true;
callButton[currentPlayer].disabled = true;
class ConnectDialog : Window
{
minClientSize = Size { 300, 100 };
- tabCycle = true, background = activeBorder, hasClose = true, text = "Connect to server";
+ tabCycle = true, background = activeBorder, hasClose = true, caption = "Connect to server";
Button ok
{
- parent = this, bevel = true, isDefault = true, text = "OK",
+ parent = this, bevel = true, isDefault = true, caption = "OK",
size = Size { w = 80 }, anchor = Anchor { horz = -48, bottom = 10 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
Button cancel
{
- parent = this, bevel = true, text = "Cancel", size = Size { w = 80 }, hotKey = escape;
+ parent = this, bevel = true, caption = "Cancel", size = Size { w = 80 }, hotKey = escape;
anchor = Anchor { horz = 48, bottom = 10 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
EditBox address
{
- parent = this, textHorzScroll = true, size = Size { w = 200 }, anchor = Anchor { top = 10 },
+ parent = this, textHorzScroll = true, size = Size { w = 200 }, anchor = Anchor { top = 10 },
line.text = "localhost"
};
}
bool result;
gotMove = false;
result = server.PlayPiece(p, direction, flip, x, y);
- validMove = true;
+ if(result)
+ validMove = true;
}
}
}
{
if(gameStarted && colorPlayed == gameState.colorTurn)
{
- Piece * piece = &pieces[selectedPiece];
if(gameState.ValidMove(gameState.colorTurn, selectedPiece, direction, flip, boardPos.x, boardPos.y))
server.PlayPiece(selectedPiece, direction, flip, boardPos.x, boardPos.y);
}
{
Piece * piece = &pieces[selectedPiece];
int mx = drag.x - offset.x, my = drag.y - offset.y;
- int rx, ry;
int x = squareDragged.x, y = squareDragged.y;
int w,h;
bool isDown = key == wheelDown || key == right || key == down;
log.inactive = bool::true;
visible = false;
- bool ProcessCommand(char * command)
+ bool ProcessCommand(const char * command)
{
cornerBlocks.server.SendMessage(command);
return false;
void OnRedraw(Surface surface)
{
PlayerColor p;
- char * s;
+ const char * s;
int len;
char temp[256];
int grandTotals[4];
{
for(c = 0; c < numTies; c++)
{
- strcat(string, cornerBlocks.playerNames[c]);
+ strcat(string, cornerBlocks.playerNames[ties[c]]);
if(c < numTies-2)
strcat(string, ", ");
else if(c < numTies-1)
void GameStarted(GameInfo gameInfo)
{
- int x,y;
int c, np = 0;
cornerBlocks.gameState.numPlayers = gameInfo.numPlayers;
void GameEnded()
{
- int c;
-
panel.ListPlayers();
cornerBlocks.gameStarted = false;
cornerBlocks.btnPass.visible = false;
}
}
- void NotifyMessage(String name, String msg)
+ void NotifyMessage(const String name, const String msg)
{
EditBox log = cornerBlocks.chat.log;
- char * format = (log.numLines > 1 || log.line.count) ?
+ const char * format = (log.numLines > 1 || log.line.count) ?
"\n%s: %s" : "%s: %s";
int len = strlen(msg);
// Avoid buffer overflow...
if(len >= MAX_F_STRING-100)
- msg[MAX_F_STRING-100] = 0;
+ ((char *)msg)[MAX_F_STRING-100] = 0;
cornerBlocks.chat.Log(format, name, msg);
}
};
}
};
-static char * dicos[Languages] = { ":englishWords.txt", ":frenchWords.txt" };
+static const char * dicos[Languages] = { ":englishWords.txt", ":frenchWords.txt" };
class CrossWordsGame
{
void GetTiles(int tilesPlayer, PlayedMove move)
{
Player player = players[tilesPlayer];
- int c;
move.numTiles = 0;
while(player.numLetters < 7 && numLettersAvailable)
}
}
- void LoadWords(char * fileName)
+ void LoadWords(const char * fileName)
{
File f = FileOpen(fileName, read);
if(f)
int numLetters = 0;
Direction direction = horizontal;
- int wordX;
- int wordY;
+ //int wordX;
+ //int wordY;
int firstX = MAXINT, lastX = MININT;
int firstY = MAXINT, lastY = MININT;
int first, last, where;
{
if(board[y][x] == empty && newBoard[y][x] != empty)
{
- wordX = x;
- wordY = y;
+ //wordX = x;
+ //wordY = y;
if(x < firstX) firstX = x;
if(y < firstY) firstY = y;
if(x > lastX) lastX = x;
void OnRedraw(Surface surface)
{
Bitmap board = boardBmp.bitmap;
- Bitmap remove = removeBmp.bitmap;
Bitmap wStone = stoneBmps[Stone::white].bitmap;
int x, y;
for(c = black; c <= white; c++)
{
Bitmap stone = stoneBmps[c].bitmap;
- int bx = (clientSize.w - board.width * scale)/2;
int drawerX = (c == black) ? blackDrawer : whiteDrawer;
int r;
/*
static ColorKey defaultKeys[] =
-{
+{
{ navy, 0.0f },
{ green, 0.1f },
{ yellow, 0.2f },
*/
/*
static ColorKey defaultKeys[] =
-{
+{
{ navy, 0.0f },
{ Color { 146, 237, 237 }, 0.2f },
{ white, 0.3f },
startX = x;
Capture();
-
+
return true;
}
if(key->percent < 0) key->percent = 0;
else if(key->percent > 1) key->percent = 1;
}
-
+
designer.Update(null);
designer.NotifyUpdate(designer.master);
}
*key = designer.gradient.keys._[designer.gradient.keys.size-1];
designer.gradient.keys.size--;
qsort(designer.gradient.keys._, designer.gradient.keys.size, sizeof(ColorKey), CompareKeys);
- Destroy(0);
+ Destroy(0);
designer.Update(null);
designer.NotifyUpdate(designer.master);
void OnRedraw(Surface surface)
{
int c;
-
+
for(c = 0; c < gradient.keys.size; c++)
{
ColorKey * key = gradient.keys._ + c;
ScrollBar smoothness
{
this, borderStyle = deep, clientSize = { 124, 18 }, position = { 16, 240 }, range = 100;
- text = "Smoothness";
+ text = "Smoothness";
void NotifyScrolling(ScrollBar scrollBar, ScrollBarAction action, int position, Key key)
{
ColorKey * key;
int c;
KeyHandle handle;
-
+
gradient.keys.size++;
key = gradient.keys._ + gradient.keys.size - 1;
x -= preview.position.x;
handle = KeyHandle { this, percent = key->percent, position = { key->percent * preview.size.w + preview.position.x - handleWidth/2, preview.position.y - 30 }, background = key->color };
handle.Create();
-
+
qsort(gradient.keys._, gradient.keys.size, sizeof(ColorKey), CompareKeys);
for(c = 0; c < gradient.keys.size; c++)
/********************************************************
- This sample demonstrates takes a screenshot of the
+ This sample takes a screenshot of the
desktop and saves it to a bitmap file.
********************************************************/
import "ecere"
class SampleSocket : Socket
{
- unsigned int OnReceive(unsigned char * buffer, unsigned int count)
+ unsigned int OnReceive(const unsigned char * buffer, unsigned int count)
{
// We only process the data if we've received enough bytes to make up the message
// This first if just checks if we have reveived enough bytes for the header
if(count >= size)
{
// We've received a complete message, so we change the contents of the recvString EditBox
- log.PutS(packet->string);
- log.PutS("\n");
+ logBox.PutS(packet->string);
+ logBox.PutS("\n");
// and we return the size of the message we've processed.
// If more data is already buffered, this method will be called again right away.
return size;
// The service
SampleService service { port = samplePort };
-EditBox log
+EditBox logBox
{
caption = "RX Sample";
hasClose = true;
form.UpdateButtonStates();
}
- unsigned int OnReceive(unsigned char * buffer, unsigned int count)
+ unsigned int OnReceive(const unsigned char * buffer, unsigned int count)
{
// We only process the data if we've received enough bytes to make up the message
// This first if just checks if we have reveived enough bytes for the header
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
// We build up a SamplePacket here with our message from the sentString EditBox
- String string = sentString.contents;
+ const String string = sentString.contents;
int len = strlen(string);
int size = sizeof(SamplePacket) + len;
SamplePacket * packet = (SamplePacket *)new byte[size];
if(socket.Connect("localhost", samplePort))
{
// We build up a SamplePacket here with our message
- String string = "Hello !";
+ const String string = "Hello !";
int len = strlen(string);
int size = sizeof(SamplePacket) + len;
SamplePacket * packet = (SamplePacket *)new byte[size];
class TrackingSocket : Socket
{
- unsigned int OnReceive(unsigned char * buffer, unsigned int count)
+ unsigned int OnReceive(const byte * buffer, unsigned int count)
{
- parser.Parse(buffer, count);
+ parser.Parse((char *)buffer, count);
// Update Things Here
return count;
{
Track object;
- void ProcessKeyword(char * keyWord)
+ void ProcessKeyword(const char * keyWord)
{
if(!strcmpi(keyWord, "object"))
{
{
MyTag tag;
- void ProcessCharacterData(char * data)
+ void ProcessCharacterData(const char * data)
{
switch(tag)
{
}
}
- void ProcessKeyword(char * keyWord)
+ void ProcessKeyword(const char * keyWord)
{
NamedLink64 nl;
EnumClassData tagData = class(MyTag).data;
this, text = "Send", size = Size { 80, 20 }, anchor = Anchor { right = 10, top = 40 }, hotKey = altS, disabled = true;
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
- char * fileName = sendFile.line.text;
+ const char * fileName = sendFile.line.text;
fileSend = FileOpen(fileName, read);
if(fileSend)
for(line = message.firstLine; line; line = line.next)
{
eComPacket * packet;
- char * string = line.text;
+ const char * string = line.text;
int size = strlen(string);
packet = (eComPacket *)new byte[sizeof(eComPacket) + size];
char recvFileName[MAX_FILENAME];
char * displayedName;
- char * localName;
+ const char * localName;
void SendBlock(uint blockSize)
{
}
}
- void SendName(char * name)
+ void SendName(const char * name)
{
eComPacket * namePacket = (eComPacket *)new byte[sizeof(eComPacket) + strlen(name)];
localName = name;
Connection connection;
MainPanel mainPanel;
- uint OnReceive(byte * buffer, uint count)
+ uint OnReceive(const byte * buffer, uint count)
{
if(count >= sizeof(eComPacket))
{
void NotifyUpdate(EditBox editBox)
{
- char * string = nameBox.contents;
+ const char * string = nameBox.contents;
OldLink link;
for(link = connections.first; link; link = link.next)
((Connection)link.data).SendName(string);
connections.Delete(connections.FindLink(connection));
}
- void OnConnect(Connection connection, char * inetAddress, char * address)
+ void OnConnect(Connection connection, const char * inetAddress, const char * address)
{
log.End();
log.Printf("\nConnected to %s (%s)", inetAddress, address);
{
this, textHorzScroll = true; size.h = editHeight, anchor = { left = 0, right = 0, bottom = 0 };
};
- virtual bool ProcessCommand(char * command);
+ virtual bool ProcessCommand(const char * command);
Bitmap bitmap;
OldList commands;
/* CONSOLE MOVEMENT */
if(shown && moving)
{
- int movement = (int)(diffTime * (movement * speed));
+ int movement = (int)(diffTime * (this.movement * speed));
if(movement)
{
case enter:
{
Item string;
- char * lineBuffer;
+ const char * lineBuffer;
char * buffer;
// Process Command in command edit box here
bool OnKeyHit(Key key, unichar ch)
{
- char * lineBuffer = commandBox.line.text;
+ const char * lineBuffer = commandBox.line.text;
char * buffer;
switch((SmartKey)key)
doneLooping = false;
command = command.prev;
commandBox.Clear();
- commandBox.PutS(((byte *) command) + sizeof(class Item));
+ commandBox.PutS(((const char *) command) + sizeof(class Item));
}
}
return false;
doneLooping = false;
command = command.next;
commandBox.Clear();
- commandBox.PutS(((byte *) command) + sizeof(class Item));
+ commandBox.PutS(((const char *) command) + sizeof(class Item));
}
}
return false;
}
}
- void Log(char * format, ...)
+ void Log(const char * format, ...)
{
if(this)
{
// height = 480;
referenceHeight = 480;
- bool ProcessCommand(char * command)
+ bool ProcessCommand(const char * command)
{
bool result = false;
char *tokens[10];
- int count = Tokenize(command, 10, tokens, false);
+ int count = Tokenize((char *)command, 10, tokens, false);
// ==== OFFLINE ====
class IRCSocket : Socket
{
- uint OnReceive(byte * recvBuffer, uint recvCount)
+ uint OnReceive(const byte * recvBuffer, uint recvCount)
{
int count;
- byte buffer[513];
- byte *tokens[10];
+ char buffer[513];
+ char *tokens[10];
count = Min(recvCount, 512);
memcpy(buffer, recvBuffer, count);
class IdentSocket : Socket
{
- uint OnReceive(byte * recvBuffer, uint recvCount)
+ uint OnReceive(const byte * recvBuffer, uint recvCount)
{
int count;
- byte buffer[1024];
+ char buffer[1024];
count = Min(recvCount, 1023);
memcpy(buffer, recvBuffer, count);
if(count > 1)
import "ecere"
-static char * indexNames[] =
+static const char * indexNames[] =
{
"index.html",
"index.htm",
#define NUM_INDEX (sizeof(indexNames) / sizeof(char *))
-static void WriteFileName(File f, char * fileName)
+static void WriteFileName(File f, const char * fileName)
{
byte ch;
int c;
f.Puts("\r\n</BODY></HTML>\r\n");
}
-static char * GetString(char * string, char * what, int count)
+static const char * GetString(const char * string, const char * what, int count)
{
int c;
bool result = true;
}
if(c<count)
{
- char * string = (char *)buffer;
+ const char * string = (const char *)buffer;
- if((string = GetString((char *)buffer, "GET ", count)))
+ if((string = GetString(string, "GET ", count)))
{
char reply[1024];
char path[MAX_LOCATION];
if(f)
{
int newsize;
- uint * indexfs = null;
+ byte * indexfs = null;
int c;
f.Seek(0, end);
class NetworkServer : Service
{
- OldList clients { offset = (uint)&((ClientConnection)0).prev };
+ OldList clients { offset = (uint)(uintptr)&((ClientConnection)0).prev };
void OnAccept()
{
ClientConnection socket { this };
import "ecere"
define app = ((MyApp)__thisModule);
+ConsoleFile con { };
class SMTPSocket : Socket
{
{
int c;
for(c = 0; c<count; c++)
- {
- //putch(buffer[c]);
- putc(buffer[c]);
- }
+ con.Putc(buffer[c]);
replied = true;
return count;
}
}
};
-void Send(char * host, char * to, char * from, File file)
+void Send(const char * host, const char * to, const char * from, File file)
{
SMTPSocket socket { };
incref socket;
if(f)
Send("mail.mailserver.com", "destaddress@destdomain.com", "srcaddress@srcdomain.com", f);
delete f;
- getch();
+ system("pause");
}
}
return 0;
}
- void AddItem(char * string, Seconds delay)
+ void AddItem(const char * string, Seconds delay)
{
this.delay = delay;
strcpy(this.string,string);
AddThread{}.AddItem(addPacket.string, addPacket.delay);
}
- void AddItem(char * string, Seconds delay)
+ void AddItem(const char * string, Seconds delay)
{
int len = strlen(string);
uint size = sizeof(class AddPacket) + len;
class Form1 : Window
{
- text = "Form1";
+ caption = "Form1";
background = activeBorder;
borderStyle = sizable;
hasMaximize = true;
Button deleteBtn
{
- this, text = "Delete", hotKey = del, size = Size { 51, 21 }, position = Point { 424, 152 }, disabled = true;
+ this, caption = "Delete", hotKey = del, size = Size { 51, 21 }, position = Point { 424, 152 }, disabled = true;
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
};
Button addBtn
{
- parent = this, text = "Add", isDefault = true, size = Size { 31, 21 }, position = Point { 432, 120 };
+ parent = this, caption = "Add", isDefault = true, size = Size { 31, 21 }, position = Point { 432, 120 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
};
Button addBtn2
{
- this, text = "Add2", position = Point { 496, 120 };
+ this, caption = "Add2", position = Point { 496, 120 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
};
ListBox listBox1
{
- this, alwaysHighLight = true, text = "listBox1", hasVertScroll = true, size = Size { 172, 268 }, position = Point { 56, 72 };
+ this, alwaysHighLight = true, caption = "listBox1", hasVertScroll = true, size = Size { 172, 268 }, position = Point { 56, 72 };
bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
{
return true;
}
};
- EditBox editBox1 { parent = this, text = "What to add", contents = "Value", hotKey = w, size = Size { 84, 19 }, position = Point { 304, 120 } };
+ EditBox editBox1 { parent = this, caption = "What to add", contents = "Value", hotKey = w, size = Size { 84, 19 }, position = Point { 304, 120 } };
Label label1 { labeledWindow = editBox1, parent = this, size = Size { 68, 13 }, position = Point { 304, 96 } };
MySocket socket {};
MySocket socket2 {};
{
char temp[256];
sprintf(temp, "Error: The value \"%s\" is already in the list!", string);
- MessageBox { text = "Test App", contents = temp }.Create();
+ MessageBox { caption = "Test App", contents = temp }.Create();
}
}