本文整理汇总了C++中cp函数的典型用法代码示例。如果您正苦于以下问题:C++ cp函数的具体用法?C++ cp怎么用?C++ cp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CalcMPCStats
// preconditions: computer has no book
void CalcMPCStats(CPlayerComputer* computer, int height) {
FILE* cpFile;
CBitBoard bb;
int nbbs[60], i, iPos;
const int iPosMin=159; // start at this line, useful if stopping and restarting
CQPosition pos;
CCalcParams *cpOld=computer->pcp;
CHeightInfo hi(height, 0, false);
CCalcParamsFixedHeight cp(hi);
computer->pcp=&cp;
computer->cd.fsPrint=0;
// header info
std::cout << 3 << " " << height << " " << kStoneValue << "\n";
// clear computer's and params
//computer->cd.iPruneMidgame=computer->cd.iPruneEndgame=0;
// clear position counts and init
for (i=0; i<60; i++)
nbbs[i]=0;
iPos=0;
// read positions from file; analyze if we should
std::string fn(fnBaseDir);
fn+="captured.pos";
if ((cpFile=fopen(fn.c_str(),"rb"))) {
while (bb.Read(cpFile)) {
pos.Initialize(bb, true);
if (nbbs[bb.NEmpty()]++ < kMaxPositions)
if (iPos++>=iPosMin)
AnalyzePosition(computer, pos);
}
fclose(cpFile);
}
// restore computer's book and params
computer->pcp=cpOld;
}
开发者ID:weltyc,项目名称:ntest,代码行数:40,代码来源:MPCCalc.cpp
示例2: main
int main(object me, string arg)
{
string src, dst, *dirs;
seteuid(geteuid(me));
if (!arg || sscanf(arg, "%s %s", src, dst)!=2 ) return
notify_fail("指令格式: cp <原档名> <目标档名> \n");
src = resolve_path(me->query("cwd"), src);
dst = resolve_path(me->query("cwd"), dst);
if( file_size(dst)==-2 ) {
dirs = explode(src, "/");
dst += "/" + dirs[sizeof(dirs)-1];
}
if( cp(src, dst) )
write("Ok.\n");
else
write("你没有足够的读写权利。\n");
return 1;
}
开发者ID:gongfuPanada,项目名称:jy,代码行数:22,代码来源:c.c
示例3: T
void Foam::ThermoParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
{
KinematicParcel<ParcelType>::writeFields(c);
label np = c.size();
IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
IOField<scalar> cp(c.fieldIOobject("cp", IOobject::NO_READ), np);
label i = 0;
forAllConstIter(typename Cloud<ParcelType>, c, iter)
{
const ThermoParcel<ParcelType>& p = iter();
T[i] = p.T_;
cp[i] = p.cp_;
i++;
}
T.write();
cp.write();
}
开发者ID:TsukasaHori,项目名称:openfoam-extend-foam-extend-3.1,代码行数:22,代码来源:ThermoParcelIO.C
示例4: main
int main(int argc, char* argv[])
{
argc -= handleOpts(argc, argv);
if (argc < 2){
fprintf(stderr, "Usage: %s [config.ini]\n", argv[0]);
exit(1);
}
optClientno = atoi(argv[optind+1]);
ConfigParser cp(argv[optind]);
cp.Parse();
for (auto& section : cp._sections){
if (section.first.find("Workload") != std::string::npos){
std::string workload = section.first;
Config cfg(&cp, workload);
// SYSTEM-SPECIFIC
std::string system_conf;
if (!optServerPort) system_conf = cfg.get<std::string>("yesql", "");
else system_conf = std::string(optServerPort);
std::string dir = cfg.get<std::string>("logdir", ".");
if (dir.back() != '/')
dir.append("/");
dir.append("client-");
dir.append(std::to_string(optClientno));
dir.append("-");
dir.append(workload);
dir.append(".txt");
SetLog(dir.c_str());
LOG("Starting a YESQL expt.\n");
int nthreads = cfg.get<int>("threads", 1);
do_experiment(nthreads, system_conf.c_str(), &cfg, false);
}
}
return 0;
}
开发者ID:mkaguilera,项目名称:yesquel,代码行数:38,代码来源:bench-wiki-yesql.cpp
示例5: do_tests
void do_tests() {
string foo, mid, all;
ASSERT(cp("/single/master.c", "/testfile"));
rm("/testfile.zerolength");
write_file("/testfile.zerolength", "");
foo = read_file("/testfile.zerolength");
ASSERT_EQ("", foo);
foo = read_bytes("/testfile");
mid = implode(explode(foo, "\n")[9..18], "\n") + "\n";
all = implode(explode(foo, "\n")[9..<1], "\n") + "\n";
ASSERT(!read_file("/single", 10, 10));
ASSERT(foo == read_file("/testfile"));
ASSERT(foo == read_file("/testfile.crlf"));
ASSERT_EQ(mid, read_file("/testfile", 10, 10));
// if we are asking more lines than in the file, return whole file
ASSERT(all == read_file("/testfile", 10, 0x7fffffff));
ASSERT(!read_file("/does_not_exist"));
ASSERT(!read_file("/testfile", 10000, 1));
}
开发者ID:thefallentree,项目名称:fluffos,代码行数:23,代码来源:read_file.c
示例6: loadconfig
static bool loadconfig(const char *fn, const char *section)
/* Loads and sets only the general configuration out of the file, named by
* 'fn', using the section 'section' therein. Returns true, if succeeded.
*/
{
CfgParse cp(fn);
if(cp.geterror() == CfgParse::NotFound) // file not found?
return false;
// Define config variables
cp.enum_vars(CONFIG_VARS);
if(!cp.section(section)) // Jump to section, if defined
return false;
do {
switch(cp.peekvar()) {
case 1: opl.setport(cp.readlong()); break;
case 14: oplforce = cp.readbool(); break;
case 23: mydb.load(cp.readstr()); break;
case 26:
if(!stricmp(cp.readstr(), "name"))
filesel.sortby = FileWnd::SortByName;
else if(!stricmp(cp.readstr(), "extension"))
filesel.sortby = FileWnd::SortByExtension;
break;
case 27:
if(!stricmp(cp.readstr(), "nothing")) onsongend = 0;
else if(!stricmp(cp.readstr(), "rewind")) onsongend = 1;
else if(!stricmp(cp.readstr(), "stop")) onsongend = 2;
break;
}
} while(!cp.geterror());
if(cp.geterror() == CfgParse::Invalid) return false; else return true;
}
开发者ID:adplug,项目名称:adplay-dos,代码行数:37,代码来源:adplay.cpp
示例7: cp
vector<int> FormanGradientVector::count_critical_simplexes(){
vector<int> cp(3,0);
for(int i=0; i<mesh->getTopSimplexesNum(); i++){
if(is_face_critical(i))
cp[2]++;
}
for(int i=0; i<mesh->getNumVertex(); i++){
if(is_vertex_critical(i)){
cp[0]++;
}
vector<int> vv = mesh->VV(i);
for(auto v : vv){
if(v < i){
if(is_edge_critical(v,i))
cp[1]++;
}
}
}
return cp;
}
开发者ID:IuricichF,项目名称:FormanGradient2D,代码行数:24,代码来源:forman_feature.cpp
示例8: phip
sp_mat Device1D::qCMatFunct(mat phin, mat phip, bool Equilibrum) {
if ( phin.n_elem != sumPoint || ( phip.n_elem != sumPoint ) )
std::cerr << "Error: input wrong phin/phip size!" << std::endl;
sp_mat cp=speye(sumPoint, sumPoint);
if (Equilibrum == true ) {
for ( int i = 0; i < bandGapArray.size(); i++) {
phip(i) = bandGapArray[i] - phin(i);
}
}
int k=0;
for ( int i=0; i < materialList.size(); i++) {
for ( int j=0; j < nyList[i]; j++) {
if (typeList[i] == Semiconductor) {
cp(k + 1, k + 1) = materialList[i].quantumCapa((double)phin(k), (double)phip(k)); //TODO: why here used to be k+1, then "cp(0, 0) = cp(1, 1);"
} else if (typeList[i]==Dielectric) {
};
k++;
};
};
return ( cp );
}
开发者ID:Oscarlight,项目名称:leno,代码行数:24,代码来源:Device1D.cpp
示例9: rayplane
bool rayplane(float nx,float ny,float nz,float xs,float ys,float zs,float xd,float yd,float zd,coordinate p1,coordinate p2,coordinate p3,coordinate p4,float* dist,coordinate* point) {
float a=xd*nx+yd*ny+zd*nz;
if(a==0)
return false;
float t=((p1.x*nx+p1.y*ny+p1.z*nz-nx*xs-ny*ys-nz*zs)/a);
if(t<0)
return false;
float x=xs+t*xd;
float y=ys+t*yd;
float z=zs+t*zd;
coordinate cp(x,y,z);
if(abs(trianglearea(p1,p3,p4)-trianglearea(p1,p4,cp)-trianglearea(p1,p3,cp)-trianglearea(p3,p4,cp))<0.000001 || abs(trianglearea(p1,p2,p3)-trianglearea(p1,p2,cp)-trianglearea(p2,p3,cp)-trianglearea(p1,p3,cp))<0.000001) {
if(dist!=NULL) {
(*dist)=t;
if(point!=NULL) {
point->x=x;
point->y=y;
point->z=z;
}
}
return true;
}
return false;
}
开发者ID:DevCool,项目名称:CPP_Dev,代码行数:24,代码来源:Functions.cpp
示例10: main
int main()
{
title("Testing Socket Server", '=');
try
{
std::cout << "\n"<<"All files will be saved in ..\\Reciever\\RecievedFiles" << "\n\n";
std::cout << "\n" << "Please check appropriate Folder to check whether file is uploaded." << "\n";
SocketSystem ss;
SocketListener sl(9080, Socket::IP6);
BlockingQueue<std::string> queue1;
Reciever cp(queue1);
sl.start(cp);
std::cout.flush();
std::cin.get();
}
catch (std::exception& ex)
{
std::cout << ex.what();
/*Verbose::show(" Exception caught:", always);
Verbose::show(std::string("\n ") + ex.what() + "\n\n");*/
}
}
开发者ID:ojuneja,项目名称:DistributedFileManagement,代码行数:24,代码来源:Reciever.cpp
示例11: parallelPlanning
bool parallelPlanning(bool output, enum SPACE_TYPE space, std::vector<enum PLANNER_TYPE> &planners, unsigned int links,
unsigned int chains, struct ConstrainedOptions &c_opt, struct AtlasOptions &a_opt, bool bench)
{
// Create a shared pointer to our constraint.
auto constraint = std::make_shared<ParallelConstraint>(links, chains);
ConstrainedProblem cp(space, constraint->createSpace(), constraint);
cp.setConstrainedOptions(c_opt);
cp.setAtlasOptions(a_opt);
cp.css->registerProjection("parallel", constraint->getProjection(cp.css));
Eigen::VectorXd start, goal;
constraint->getStart(start);
constraint->getGoal(goal);
cp.setStartAndGoalStates(start, goal);
cp.ss->setStateValidityChecker(std::bind(&ParallelConstraint::isValid, constraint, std::placeholders::_1));
if (!bench)
return parallelPlanningOnce(cp, planners[0], output);
else
return parallelPlanningBench(cp, planners);
}
开发者ID:ompl,项目名称:ompl,代码行数:24,代码来源:ConstrainedPlanningImplicitParallel.cpp
示例12: switch
// A non-NULL pointer is a sprite mask, a NULL pointer means bbox should be used.
void *get_collision_mask(sprite* spr, unsigned char* input_data, collision_type ct) // It is called for every subimage of every sprite loaded.
{
switch (ct)
{
case ct_precise:
{
const unsigned int w = spr->width, h = spr->height;
unsigned char* colldata = new unsigned char[w*h];
for (unsigned int rowindex = 0; rowindex < h; rowindex++)
{
for(unsigned int colindex = 0; colindex < w; colindex++)
{
colldata[rowindex*w + colindex] = (input_data[4*(rowindex*w + colindex) + 3] != 0) ? 1 : 0; // If alpha != 0 then 1 else 0.
}
}
return colldata;
}
case ct_bbox: return 0;
case ct_ellipse:
{
// Create ellipse inside bbox.
const unsigned int w = spr->width, h = spr->height;
unsigned char* colldata = new unsigned char[w*h](); // Initialize all elements to 0.
const bbox_rect_t bbox = spr->bbox;
const unsigned int a = max(bbox.right-bbox.left, bbox.bottom-bbox.top)/2, // Major radius.
b = min(bbox.right-bbox.left, bbox.bottom-bbox.top)/2; // Minor radius.
const unsigned int xc = (bbox.right+bbox.left)/2, // Center of ellipse.
yc = (bbox.bottom+bbox.top)/2;
const long long a_2 = a*a, b_2 = b*b, a_2b_2 = a*a*b*b;
const int minX = max(bbox.left-2, 0),
minY = max(bbox.top-2, 0),
maxX = min(bbox.right+2, w),
maxY = min(bbox.bottom+2, h);
for (int y = minY; y < maxY; y++)
{
for(int x = minX; x < maxX; x++)
{
const int xcp = x-xc, ycp = y-yc; // Center to point.
const bool is_inside_ellipse = b_2*xcp*xcp + a_2*ycp*ycp <= a_2b_2;
colldata[y*w + x] = (is_inside_ellipse ? 1 : 0); // If point inside ellipse, 1, else 0.
}
}
return colldata;
}
case ct_diamond:
{
// Create diamond inside bbox.
const unsigned int w = spr->width, h = spr->height;
unsigned char* colldata = new unsigned char[w*h](); // Initialize all elements to 0.
const bbox_rect_t bbox = spr->bbox;
// Diamond corners.
const int xl = bbox.left, yl = (bbox.top + bbox.bottom)/2,
xr = bbox.right, yr = (bbox.top + bbox.bottom)/2,
xt = (bbox.left + bbox.right)/2, yt = bbox.top,
xb = (bbox.left + bbox.right)/2, yb = bbox.bottom;
const int xlt = xt-xl, ylt = yt-yl, // Left corner to top corner.
xlb = xb-xl, ylb = yb-yl, // Left corner to bottom corner.
xrt = xt-xr, yrt = yt-yr, // Right corner to top corner.
xrb = xb-xr, yrb = yb-yr; // Right corner to bottom corner.
const int minX = max(bbox.left-2, 0),
minY = max(bbox.top-2, 0),
maxX = min(bbox.right+2, w),
maxY = min(bbox.bottom+2, h);
for (int y = minY; y < maxY; y++)
{
for(int x = minX; x < maxX; x++)
{
const int xlp = x-xl, ylp = y-yl; // Left corner to point.
const int xrp = x-xr, yrp = y-yr; // Right corner to point.
const bool is_inside_diamond = cp(xlt, -ylt, xlp, -ylp) <= 0 && // Use cross-product to determine whether inside or outside diamond.
cp(xlb, -ylb, xlp, -ylp) >= 0 &&
cp(xrt, -yrt, xrp, -yrp) >= 0 &&
cp(xrb, -yrb, xrp, -yrp) <= 0;
colldata[y*w + x] = (is_inside_diamond ? 1 : 0); // If point inside diamond, 1, else 0.
}
}
return colldata;
}
case ct_polygon: return 0;
case ct_circle: //NOTE: Not tested.
{
// Create circle fitting inside bbox.
const unsigned int w = spr->width, h = spr->height;
unsigned char* colldata = new unsigned char[w*h](); // Initialize all elements to 0.
const bbox_rect_t bbox = spr->bbox;
const unsigned int r = min(bbox.right-bbox.left, bbox.bottom-bbox.top)/2; // Radius.
const unsigned int xc = (bbox.right+bbox.left)/2, // Center of circle.
yc = (bbox.bottom+bbox.top)/2;
//.........这里部分代码省略.........
开发者ID:DarkAceZ,项目名称:enigma-dev,代码行数:101,代码来源:placeholderlinks.cpp
示例13: plotSFspec
//.........这里部分代码省略.........
TString effKind =effDataKindString(sfKindLongStr);
TString dataKind=effKind;
TMatrixD *sf=NULL, *sf1ErrLo=NULL, *sf1ErrHi=NULL;
TMatrixD *systRelErr=NULL, sf2ErrLo(nEtBins,nEtaBins), sf2ErrHi(nEtBins,nEtaBins);
TMatrixD *systRelErrTot=NULL, sf3ErrLo(nEtBins,nEtaBins), sf3ErrHi(nEtBins,nEtaBins);
// load the scale factors
if (!loadEGammaEff(fname,"sf",&sf,&sf1ErrLo,&sf1ErrHi)) {
std::cout << "failed to load EGammaSf\n";
return;
}
HERE("load egamma ok");
systRelErr=loadMatrix(fname,"sf_syst_rel_error_egamma",nEtBins,nEtaBins,1);
if (!systRelErr) return;
systRelErrTot=loadMatrix(fname,"sf_syst_rel_error",nEtBins,nEtaBins,1);
if (!systRelErrTot) return;
HERE("add errors");
addInQuadrature(*sf,*sf1ErrLo, *systRelErr, sf2ErrLo);
addInQuadrature(*sf,*sf1ErrHi, *systRelErr, sf2ErrHi);
addInQuadrature(*sf,*sf1ErrLo, *systRelErrTot, sf3ErrLo);
addInQuadrature(*sf,*sf1ErrHi, *systRelErrTot, sf3ErrHi);
HERE("create graphs");
TGraphAsymmErrors* gr1=getAsymGraph(vsEt, etBinSet,etaBinSet,iBin,*sf,*sf1ErrLo,*sf1ErrHi);
gr1->GetXaxis()->SetMoreLogLabels();
gr1->GetXaxis()->SetNoExponent();
gr1->Print("range");
TGraphAsymmErrors* gr2=getAsymGraph(vsEt, etBinSet,etaBinSet,iBin,*sf,sf2ErrLo,sf2ErrHi);
gr2->GetXaxis()->SetMoreLogLabels();
gr2->GetXaxis()->SetNoExponent();
gr2->Print("range");
TGraphAsymmErrors* gr3=getAsymGraph(vsEt, etBinSet,etaBinSet,iBin,*sf,sf3ErrLo,sf3ErrHi);
gr3->GetXaxis()->SetMoreLogLabels();
gr3->GetXaxis()->SetNoExponent();
gr3->Print("range");
double *loc_etBinLimits=DYTools::getEtBinLimits(etBinSet);
double *loc_etaBinLimits=DYTools::getEtaBinLimits(etaBinSet);
int signedEta=DYTools::signedEtaBinning(etaBinSet);
TString binStrForTitle=(vsEt) ? TString(Form(" %5.3lf #leq %s #leq %5.3lf",loc_etaBinLimits[iBin],(signedEta)?"#eta":"abs(#eta)",loc_etaBinLimits[iBin+1])) :
TString(Form(" %2.0lf #leq #it{E}_{T} #leq %2.0lf GeV",loc_etBinLimits[iBin],loc_etBinLimits[iBin+1]));
TString cpTitle=dataKind+ binStrForTitle;
TString xAxisTitle="#it{E}_{T} [GeV]";
if (!vsEt) xAxisTitle=(signedEta) ? "#eta" : "|#eta|";
ComparisonPlot_t cp(ComparisonPlot_t::_ratioPlain,"comp",cpTitle,
xAxisTitle,effKind + TString(" scale factor"),"ratio");
cp.SetRefIdx(-111); // no ratio plot
if (vsEt) cp.SetLogx();
cp.AddLine(10.,1.,500.,1.,kBlack,2);
TCanvas *cx=new TCanvas("cx","cx",600,600);
SetSideSpaces(cx,0.05,0.,0.,0.02);
gr1->GetYaxis()->SetTitleOffset(1.4);
//cp.AddGraph(gr3,label3,"LPE",43); //kRed+3);
cp.AddGraph(gr3,label3,"LPE",kRed); //kRed+3);
cp.AddGraph(gr2,label2,"LPE",38); //kBlue+2);
cp.AddGraph(gr1,label1," PE",kBlack,20); //24
cp.Draw(cx,0,"png",0);
cp.TransLegend(transLegendX, transLegendY);
cp.WidenLegend(0.25,0.);
cx->Update();
// Save file
if (saveFileTag.Length()) {
TString outfname=TString("fig-sf-egamma-") + cpTitle;
outfname.ReplaceAll(" #leq "," ");
outfname.ReplaceAll(" ","_");
outfname.ReplaceAll("(#eta)","Eta");
outfname.ReplaceAll("#eta","eta");
outfname.ReplaceAll(".","_");
outfname.ReplaceAll("#it{E}_{T}","Et");
//fname.Append(".png");
std::cout << "outfname=" << outfname << "\n";
TString locOutDir=TString("plots") + saveFileTag;
if (doSave) {
locOutDir.ReplaceAll("--","");
SaveCanvas(cx,outfname,locOutDir);
}
else {
std::cout << "... canvas not saved, as requested\n";
std::cout << " locOutDir=" << locOutDir << "\n";
}
}
return ;
}
开发者ID:andjuo,项目名称:DYee,代码行数:101,代码来源:plotSFspec.C
示例14: mv
static int mv(const std::string& src, const std::string& dest)
{
cp(src, dest);
return remove(src.c_str());
}
开发者ID:zand3rs,项目名称:fun2,代码行数:5,代码来源:default_unli_handler.cpp
示例15: VALIDATE_ARG_COUNT
//.........这里部分代码省略.........
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument=0;
r_error.expected=Variant::DICTIONARY;
r_ret=RTR("Not based on a script");
return;
}
GDScript *p = base.ptr();
Vector<StringName> sname;
while(p->_owner) {
sname.push_back(p->name);
p=p->_owner;
}
sname.invert();
if (!p->path.is_resource_file()) {
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument=0;
r_error.expected=Variant::DICTIONARY;
r_ret=Variant();
r_ret=RTR("Not based on a resource file");
return;
}
NodePath cp(sname,Vector<StringName>(),false);
Dictionary d;
d["@subpath"]=cp;
d["@path"]=p->path;
p = base.ptr();
while(p) {
for(Set<StringName>::Element *E=p->members.front();E;E=E->next()) {
Variant value;
if (ins->get(E->get(),value)) {
String k = E->get();
if (!d.has(k)) {
d[k]=value;
}
}
}
p=p->_base;
}
r_ret=d;
}
}
} break;
case DICT2INST: {
开发者ID:pkowal1982,项目名称:godot,代码行数:67,代码来源:gd_functions.cpp
示例16: assert
int gameswf::tools::process_swf(tu_file* swf_out, tu_file* in, const process_options& options)
{
assert(in && in->get_error() == TU_FILE_NO_ERROR);
assert(swf_out && swf_out->get_error() == TU_FILE_NO_ERROR);
// @@ Copied & adapted from movie_def_impl::read()
// @@ TODO share this wrapper code somehow (also with gameswf_parser)
Uint32 file_start_pos = in->get_position();
Uint32 header = in->read_le32();
Uint32 file_length = in->read_le32();
Uint32 file_end_pos = file_start_pos + file_length;
int version = (header >> 24) & 255;
if ((header & 0x0FFFFFF) != 0x00535746
&& (header & 0x0FFFFFF) != 0x00535743)
{
// ERROR
log_error("gameswf::movie_def_impl::read() -- file does not start with a SWF header!\n");
return 1;
}
bool compressed = (header & 255) == 'C';
IF_VERBOSE_PARSE(log_msg("version = %d, file_length = %d\n", version, file_length));
tu_file* original_in = NULL;
if (compressed)
{
#if TU_CONFIG_LINK_TO_ZLIB == 0
log_error("gameswf can't read zipped SWF data; TU_CONFIG_LINK_TO_ZLIB is 0!\n");
return -1;
#endif
IF_VERBOSE_PARSE(log_msg("file is compressed.\n"));
original_in = in;
// Uncompress the input as we read it.
in = zlib_adapter::make_inflater(original_in);
// Subtract the size of the 8-byte header, since
// it's not included in the compressed
// stream length.
file_end_pos = file_length - 8;
}
lfl_stream str(in);
if (options.m_zip_whole_file)
{
// @@ TODO not implemented yet.
log_error("gameswf::tools::process_swf(): options.m_zip_whole_file is not implemented! Output will not be zipped.\n");
}
//
// Start the output file
//
int output_file_start_pos = swf_out->get_position();
swf_out->write_le32(0x06535746); // Flash 6 header, uncompressed
// File length (need to overwrite later with the actual value.
int output_file_length_pos = swf_out->get_position();
swf_out->write_le32(0);
float frame_rate = 30.f;
int frame_count = 0;
{
copy_helper cp(in, swf_out); // copies everything that's read in this scope.
rect dummy_frame_size;
dummy_frame_size.read(&str);
frame_rate = str.read_u16() / 256.0f;
frame_count = str.read_u16();
str.align();
bool success = cp.do_copy();
if (!success)
{
// Error!
log_error("gameswf::tools::process_swf() -- unable to copy header data!\n");
return 1;
}
}
// m_playlist.resize(m_frame_count);
// IF_VERBOSE_PARSE(m_frame_size.print());
IF_VERBOSE_PARSE(log_msg("frame rate = %f, frames = %d\n", frame_rate, frame_count));
while ((Uint32) str.get_position() < file_end_pos)
{
copy_helper cp(in, swf_out);
int tag_type = str.open_tag();
if (options.m_remove_image_data
&& tag_type == 8)
{
// Don't need no stinkin jpeg tables.
str.close_tag();
//.........这里部分代码省略.........
开发者ID:xuxiandi,项目名称:LiquidFL,代码行数:101,代码来源:gameswf_tools.cpp
示例17: time
void Log::Open(bool plain){
char buffer[1000];
if( Lmagic != 95768){
Lmagic = 95768;
First = true;
}
if(plain == true){ // Textfile Logging
plaintext = true;
// char c[400];
time_t now1;
time(&now1);
struct tm *now2;
now2 = localtime(&now1);
string filename = G->info->datapath + slash + "Logs" + slash;
// DDD MMM DD HH:MM:SS YYYY_X - NTAI.log
filename += to_string(now2->tm_mon+1)+"-" +to_string(now2->tm_mday) + "-" +to_string(now2->tm_year + 1900) +"-" +to_string(now2->tm_hour) +"_" +to_string(now2->tm_min) +"["+to_string(G->Cached->team)+"]XE9.79.log";
//sprintf(c, "%2.2d-%2.2d-%4.4d %2.2d%2.2d [%d]XE9.79.log",
// now2->tm_mon+1, now2->tm_mday, now2->tm_year + 1900, now2->tm_hour,
// now2->tm_min, G->Cached->team);
//filename += c;
strcpy(buffer, filename.c_str());
G->cb->GetValue(AIVAL_LOCATE_FILE_W, buffer);
logFile.open(buffer);
if(logFile.is_open() == false){
logFile.close();
logFile.open(buffer);
if(logFile.is_open() == false){
iprint(string("Error!!! ") + filename + string(" refused to open!"));
verbose = true;
return;
}
}
header(" :: NTAI XE9.79 Log File \n :: Programmed and maintained by AF/T.Nowell \n :: Copyright (C) 2004-7 Tom Nowell/AF \n");
logFile << " :: Game started: " << now2->tm_mday << "." << now2->tm_mon << "." << 1900 + now2->tm_year << " " << now2->tm_hour << ":" << now2->tm_min << ":" << now2->tm_sec << endl << endl << flush;
TdfParser cp(G);
cp.LoadFile("modinfo.tdf");
logFile << " :: " << cp.SGetValueMSG("MOD\\Name") << endl << flush;
logFile << " :: " << cp.SGetValueMSG("MOD\\Description") << endl << flush;
if(First == true) logFile << " :: First instance of NTAI" << endl;
startupscript = new TdfParser(G);
startupscript->LoadFile("script.txt");
vector<string> names;
for(int n=0; n<MAX_TEAMS; n++){
string s = startupscript->SGetValueDef("", string("GAME\\PLAYER") + to_string(n) + "\\name");
if(s != string("")){
names.push_back(s + " : player :: " + to_string(n));
PlayerNames[n] = s;
} else{
PlayerNames[n] = "spring_engine";
}
logFile << " :: " << PlayerNames[n] << endl;
}
logFile << " :: AI DLL's in game" << endl << flush;
vector<string> AInames;
for(int n=0; n<MAX_TEAMS; n++){
string s = startupscript->SGetValueDef("", string("GAME\\TEAM") + to_string(n) + "\\AIDLL");
if(s != string("")){
AInames.push_back(s + " : AI :: " + to_string(n));
logFile << " :: "<<s << " : AI :: " << to_string(n) << endl << flush;
}
}
logFile << endl << flush;
}else{ // HTML logging
char c[400];
time_t now1;
time(&now1);
struct tm *now2;
now2 = localtime(&now1);
string filename = G->info->tdfpath;
filename += slash;
filename += "Logs";
filename += slash;
// DDD MMM DD HH:MM:SS YYYY_X - NTAI.htm
sprintf(c, "%2.2d-%2.2d-%4.4d %2.2d%2.2d [%d] - NTAIXE9.79.htm",
now2->tm_mon+1, now2->tm_mday, now2->tm_year + 1900, now2->tm_hour,
now2->tm_min, G->Cached->team);
filename += c;
strcpy(buffer, filename.c_str());
G->cb->GetValue(AIVAL_LOCATE_FILE_W, buffer);
logFile.open(buffer);
plaintext = false;
string mu ="</table><style type='text/css'>\n<!--\nbody,td,th {\n font-family: sans-serif;\n color: #111111;\nfont-size: 12px;\n\n}\nbody {\n background-color: #FFFFFF;\n\n}\n.c {color: #FF2222}\n.e {color: #FFCC11}\n-->\n</style>\n";
mu+= "<b><br><br>NTAI XE Log File <br>\n<span class='c'>Programmed and maintained by AF Copyright (C) 2006 AF<br>\nReleased under the GPL 2.0 Liscence </p></span></b><br> \n<table width='98%'border='0' cellpadding='0' cellspacing='0' bordercolor='#999999'>\n";
header(mu);
time_t tval;
char buf[128];
tval = time(NULL);
tm* now = localtime(&tval);
strftime(buf, sizeof(buf), "<b><p>Game started: <span class='c'> %B %d %Y %I:%M %p.</p></span></b>", now);
print(buf);
TdfParser cp(G);
cp.LoadFile("modinfo.tdf");
logFile << " :: " << cp.SGetValueMSG("MOD\\Name") << endl << flush;
if(First == true) logFile << " :: First instance of NTAI" << endl << flush;
}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:97,代码来源:Log.cpp
示例18: Handle
Handle(Geom_BSplineCurve) CFunctionToBspline::CFunctionToBsplineImpl::Curve()
{
bool interpolate = true;
std::vector<ChebSegment> segments = approxSegment(_umin, _umax, 1);
int N = _degree + 1;
math_Matrix Mt = monimial_to_bezier(N)*cheb_to_monomial(N);
// get estimated error and create bspline segments
std::vector<Handle(Geom_BSplineCurve)> curves;
double errTotal = 0.;
std::vector<ChebSegment>::iterator it = segments.begin();
for (; it != segments.end(); ++it) {
// get control points
ChebSegment& seg = *it;
math_Vector cpx = Mt*seg.cx;
math_Vector cpy = Mt*seg.cy;
math_Vector cpz = Mt*seg.cz;
TColgp_Array1OfPnt cp(1,cpx.Length());
for (int i = 1; i <= cpx.Length(); ++i) {
gp_Pnt p(cpx(i-1), cpy(i-1), cpz(i-1));
cp.SetValue(i, p);
}
if (interpolate) {
gp_Pnt pstart(_xfunc.value(seg.umin), _yfunc.value(seg.umin), _zfunc.value(seg.umin));
gp_Pnt pstop (_xfunc.value(seg.umax), _yfunc.value(seg.umax), _zfunc.value(seg.umax));
cp.SetValue(1, pstart);
cp.SetValue(cpx.Length(), pstop);
}
// create knots and multiplicity vector
TColStd_Array1OfReal knots(1,2);
knots.SetValue(1, seg.umin);
knots.SetValue(2, seg.umax);
TColStd_Array1OfInteger mults(1,2);
mults.SetValue(1, _degree+1);
mults.SetValue(2, _degree+1);
Handle(Geom_BSplineCurve) curve = new Geom_BSplineCurve(cp, knots, mults, _degree);
curves.push_back(curve);
if (seg.error > errTotal) {
errTotal = seg.error;
}
}
_err = errTotal;
// concatenate c1 the bspline curves
Handle(Geom_BSplineCurve) result = concatC1(curves);
#ifdef DEBUG
LOG(INFO) << "Result of BSpline approximation of function:";
LOG(INFO) << " approximation error = " << errTotal;
LOG(INFO) << " number of control points = " << result->NbPoles();
LOG(INFO) << " number of segments = " << curves.size();
#endif
return result;
}
开发者ID:Felipeasg,项目名称:tigl,代码行数:62,代码来源:CFunctionToBspline.cpp
示例19: airnode
void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
MapNode airnode(CONTENT_AIR);
MapNode waternode(c_water_source);
MapNode lavanode(c_lava_source);
MapNode liquidnode = ps->range(0, 4) ? lavanode : waternode;
v3s16 startp(orp.X, orp.Y, orp.Z);
startp += of;
v3f fp = orp + vec * f;
fp.X += 0.1 * ps->range(-10, 10);
fp.Z += 0.1 * ps->range(-10, 10);
v3s16 cp(fp.X, fp.Y, fp.Z);
s16 d0 = -rs/2;
s16 d1 = d0 + rs;
if (randomize_xz) {
d0 += ps->range(-1, 1);
d1 += ps->range(-1, 1);
}
bool flat_cave_floor = !large_cave && ps->range(0, 2) == 2;
for (s16 z0 = d0; z0 <= d1; z0++) {
s16 si = rs / 2 - MYMAX(0, abs(z0) - rs / 7 - 1);
for (s16 x0 = -si - ps->range(0,1); x0 <= si - 1 + ps->range(0,1); x0++) {
s16 maxabsxz = MYMAX(abs(x0), abs(z0));
s16 si2 = is_ravine ? MYMIN(ps->range(25, 26), ar.Y) :
rs / 2 - MYMAX(0, maxabsxz - rs / 7 - 1);
for (s16 y0 = -si2; y0 <= si2; y0++) {
// Make better floors in small caves
if(flat_cave_floor && y0 <= -rs/2 && rs<=7)
continue;
if (large_cave_is_flat) {
// Make large caves not so tall
if (rs > 7 && abs(y0) >= rs / 3)
continue;
}
v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
p += of;
if (vm->m_area.contains(p) == false)
continue;
u32 i = vm->m_area.index(p);
// Don't replace air or water or lava
content_t c = vm->m_data[i].getContent();
if (c == CONTENT_AIR || c == c_water_source || c == c_lava_source)
continue;
if (large_cave) {
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
int full_ymax = node_max.Y + MAP_BLOCKSIZE;
if (flooded && full_ymin < water_level && full_ymax > water_level)
vm->m_data[i] = (p.Y <= water_level) ? waternode : airnode;
else if (flooded && full_ymax < water_level)
vm->m_data[i] = (p.Y < startp.Y - 4) ? liquidnode : airnode;
else
vm->m_data[i] = airnode;
} else {
vm->m_data[i] = airnode;
vm->m_flags[i] |= VMANIP_FLAG_CAVE;
}
}
}
}
}
开发者ID:Imberflur,项目名称:minetest,代码行数:73,代码来源:cavegen.cpp
示例20: cd
void cq::cd(by) { cf->cd(cp(cs.co())); }
开发者ID:vinriviere,项目名称:m68k-atari-mint-gcc,代码行数:1,代码来源:pr85421.C
注:本文中的cp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论