mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Syncing uppdev
git-svn-id: svn://ultimatepp.org/upp/trunk@1825 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ea7d86aacd
commit
6a809a7a5d
9 changed files with 157 additions and 12 deletions
|
|
@ -235,7 +235,6 @@ void World::Step()
|
||||||
for(int i = 0; i < 8192; i++)
|
for(int i = 0; i < 8192; i++)
|
||||||
nc.gen[i] = (rand() & 1) ? c.gen[i] : pc.gen[i];
|
nc.gen[i] = (rand() & 1) ? c.gen[i] : pc.gen[i];
|
||||||
while((rand() & 5) == 0) {
|
while((rand() & 5) == 0) {
|
||||||
LOG("...and mutating");
|
|
||||||
nc.color = Color(127 + (((rand() & 15) + c.color.GetR() - 7) & 127),
|
nc.color = Color(127 + (((rand() & 15) + c.color.GetR() - 7) & 127),
|
||||||
127 + (((rand() & 15) + c.color.GetG() - 7) & 127),
|
127 + (((rand() & 15) + c.color.GetG() - 7) & 127),
|
||||||
127 + (((rand() & 15) + c.color.GetB() - 7) & 127));
|
127 + (((rand() & 15) + c.color.GetB() - 7) & 127));
|
||||||
|
|
@ -252,12 +251,12 @@ void World::Step()
|
||||||
born++;
|
born++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = 0; i < 1024; i++) {
|
/* for(int i = 0; i < 1024; i++) {
|
||||||
spot[i][0].kind = TRAP;
|
spot[i][0].kind = TRAP;
|
||||||
spot[i][PMSK].kind = TRAP;
|
spot[i][PMSK].kind = TRAP;
|
||||||
spot[0][i].kind = TRAP;
|
spot[0][i].kind = TRAP;
|
||||||
spot[PMSK][i].kind = TRAP;
|
spot[PMSK][i].kind = TRAP;
|
||||||
}
|
}*/
|
||||||
Title(String().Cat() << "Step: " << step << " Gen: " << gen << ", pop: " << creature.GetCount()
|
Title(String().Cat() << "Step: " << step << " Gen: " << gen << ", pop: " << creature.GetCount()
|
||||||
<< ", born: " << born << ", died: " << died << " best: " << best);
|
<< ", born: " << born << ", died: " << died << " best: " << best);
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
@ -278,10 +277,10 @@ World::World()
|
||||||
p.kind = GRASS;
|
p.kind = GRASS;
|
||||||
p.energy = rand();
|
p.energy = rand();
|
||||||
}
|
}
|
||||||
if(x == 0 || y == 0 || x == PMSK || y == PMSK) {
|
// if(x == 0 || y == 0 || x == PMSK || y == PMSK) {
|
||||||
p.kind = TRAP;
|
// p.kind = TRAP;
|
||||||
p.energy = 0;
|
// p.energy = 0;
|
||||||
}
|
// }
|
||||||
p.creature = NULL;
|
p.creature = NULL;
|
||||||
}
|
}
|
||||||
if(PromptYesNo("Restore creatures from the previous run?")) {
|
if(PromptYesNo("Restore creatures from the previous run?")) {
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,17 @@ void Register(const char *name, Callback1<XmlRpcData&> cb)
|
||||||
String XmlRpcExecute(const String& request)
|
String XmlRpcExecute(const String& request)
|
||||||
{
|
{
|
||||||
XmlParser p(request);
|
XmlParser p(request);
|
||||||
|
XmlRpcData data;
|
||||||
|
String methodname;
|
||||||
try {
|
try {
|
||||||
String r = XmlHeader();
|
String r = XmlHeader();
|
||||||
r << "<methodResponse>\r\n";
|
r << "<methodResponse>\r\n";
|
||||||
p.ReadPI();
|
p.ReadPI();
|
||||||
p.PassTag("methodCall");
|
p.PassTag("methodCall");
|
||||||
p.PassTag("methodName");
|
p.PassTag("methodName");
|
||||||
String methodname = p.ReadText();
|
methodname = p.ReadText();
|
||||||
LLOG("method name: " << methodname);
|
LLOG("method name: " << methodname);
|
||||||
p.PassEnd();
|
p.PassEnd();
|
||||||
XmlRpcData data;
|
|
||||||
data.in = ParseXmlRpcParams(p);
|
data.in = ParseXmlRpcParams(p);
|
||||||
int q = xmlrpcmap.Find(methodname);
|
int q = xmlrpcmap.Find(methodname);
|
||||||
if(q >= 0) {
|
if(q >= 0) {
|
||||||
|
|
@ -33,8 +34,13 @@ String XmlRpcExecute(const String& request)
|
||||||
p.PassEnd();
|
p.PassEnd();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
catch(XmlError e) { // Add error handling!
|
catch(XmlError e) {
|
||||||
LOG("XmlError " << e << ": " << p.GetPtr());
|
LLOG("XmlError " << e << ": " << p.GetPtr());
|
||||||
|
return FormatXmlRpcError(1, methodname + " XML Error: " + e);
|
||||||
|
}
|
||||||
|
catch(ValueTypeMismatch) {
|
||||||
|
LLOG("ValueTypeMismatch at parameter " << data.ii);
|
||||||
|
return FormatXmlRpcError(2, methodname + " Value type mismatch at parameter " + AsString(data.ii));
|
||||||
}
|
}
|
||||||
return Null;
|
return Null;
|
||||||
}
|
}
|
||||||
|
|
@ -60,6 +66,7 @@ Value XmlRpcCall(const char *name, XmlRpcData& param)
|
||||||
}
|
}
|
||||||
catch(XmlError e) {
|
catch(XmlError e) {
|
||||||
LOG("XmlError " << e << ": " << p.GetPtr());
|
LOG("XmlError " << e << ": " << p.GetPtr());
|
||||||
|
return ErrorValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return param.in.GetCount() ? param.in[0] : Null;
|
return param.in.GetCount() ? param.in[0] : Null;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ CONSOLE_APP_MAIN
|
||||||
DDUMP(XmlRpcExecute(r));
|
DDUMP(XmlRpcExecute(r));
|
||||||
|
|
||||||
XmlRpcData d;
|
XmlRpcData d;
|
||||||
d << 12 << "-" << 22;
|
d << "12" << "-" << 22;
|
||||||
DDUMP(XmlRpcCall("compute", d));
|
DDUMP(XmlRpcCall("compute", d));
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
|
|
|
||||||
21
uppdev/asmopt/asmopt.cpp
Normal file
21
uppdev/asmopt/asmopt.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include <Core/Core.h>
|
||||||
|
|
||||||
|
using namespace Upp;
|
||||||
|
|
||||||
|
int Count(const Vector<String>& v, const String& x)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for(int i = 0; i < v.GetCount(); i++)
|
||||||
|
if(v[i] == x)
|
||||||
|
count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CONSOLE_APP_MAIN
|
||||||
|
{
|
||||||
|
Vector<String> x;
|
||||||
|
for(int i = 0; i < 1000; i++)
|
||||||
|
x.Add(AsString(Random(100)));
|
||||||
|
Cout() << Count(x, "50");
|
||||||
|
}
|
||||||
11
uppdev/asmopt/asmopt.upp
Normal file
11
uppdev/asmopt/asmopt.upp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
optimize_speed;
|
||||||
|
|
||||||
|
uses
|
||||||
|
Core;
|
||||||
|
|
||||||
|
file
|
||||||
|
asmopt.cpp;
|
||||||
|
|
||||||
|
mainconfig
|
||||||
|
"" = "";
|
||||||
|
|
||||||
4
uppdev/asmopt/init
Normal file
4
uppdev/asmopt/init
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#ifndef _asmopt_icpp_init_stub
|
||||||
|
#define _asmopt_icpp_init_stub
|
||||||
|
#include "Core/init"
|
||||||
|
#endif
|
||||||
9
uppdev/guimtbug/guimtbug.upp
Normal file
9
uppdev/guimtbug/guimtbug.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
uses
|
||||||
|
CtrlLib;
|
||||||
|
|
||||||
|
file
|
||||||
|
main.cpp;
|
||||||
|
|
||||||
|
mainconfig
|
||||||
|
"" = "GUI MT";
|
||||||
|
|
||||||
4
uppdev/guimtbug/init
Normal file
4
uppdev/guimtbug/init
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#ifndef _guimtbug_icpp_init_stub
|
||||||
|
#define _guimtbug_icpp_init_stub
|
||||||
|
#include "CtrlLib/init"
|
||||||
|
#endif
|
||||||
90
uppdev/guimtbug/main.cpp
Normal file
90
uppdev/guimtbug/main.cpp
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
#include <CtrlLib/CtrlLib.h>
|
||||||
|
|
||||||
|
using namespace Upp;
|
||||||
|
|
||||||
|
class TestThread : public TopWindow
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
bool stop;
|
||||||
|
void buttonCb(void);
|
||||||
|
Thread thr;
|
||||||
|
virtual void thrCb(void);
|
||||||
|
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
ProgressIndicator progress;
|
||||||
|
Button button;
|
||||||
|
StatusBar status;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef TestThread CLASSNAME;
|
||||||
|
|
||||||
|
TestThread();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void TestThread::thrCb(void)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
GuiLock __;
|
||||||
|
status.Set("Running, " + FormatInt(thr.GetCount()) + " threads");
|
||||||
|
}
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
GuiLock __;
|
||||||
|
if(progress < 100)
|
||||||
|
progress++;
|
||||||
|
else
|
||||||
|
progress = 0;
|
||||||
|
if(stop)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Sleep(1000);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
GuiLock __;
|
||||||
|
status.Set("Idle....");
|
||||||
|
}
|
||||||
|
PostCallback(THISBACK(Stop));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestThread::Stop()
|
||||||
|
{
|
||||||
|
button.SetLabel("START");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestThread::buttonCb(void)
|
||||||
|
{
|
||||||
|
if(stop)
|
||||||
|
{
|
||||||
|
stop = false;
|
||||||
|
button.SetLabel("STOP");
|
||||||
|
thr.Run(THISBACK(thrCb));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
stop = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
TestThread::TestThread()
|
||||||
|
{
|
||||||
|
SetRect(0, 0, 300, 150);
|
||||||
|
Add(button);
|
||||||
|
button.TopPos(90, 30).HCenterPos(100);
|
||||||
|
button.SetLabel("START");
|
||||||
|
Add(progress);
|
||||||
|
progress.TopPos(30, 40).HCenterPos(250);
|
||||||
|
progress.Set(0, 100);
|
||||||
|
AddFrame(status);
|
||||||
|
status.Set(" ");
|
||||||
|
|
||||||
|
stop = true;
|
||||||
|
button <<= THISBACK(buttonCb);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI_APP_MAIN
|
||||||
|
{
|
||||||
|
TestThread().Run();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue