darkplaces.diff
| cl_demo.c | ||
|---|---|---|
| 303 | 303 |
return; |
| 304 | 304 |
} |
| 305 | 305 | |
| 306 |
// write a disconnect message to the demo file |
|
| 306 |
// write a disconnect message to the demo file
|
|
| 307 | 307 |
// LordHavoc: don't replace the cl_message when doing this |
| 308 | 308 |
buf.data = bufdata; |
| 309 | 309 |
buf.maxsize = sizeof(bufdata); |
| ... | ... | |
| 311 | 311 |
MSG_WriteByte(&buf, svc_disconnect); |
| 312 | 312 |
CL_WriteDemoMessage(&buf); |
| 313 | 313 | |
| 314 |
// finish up |
|
| 314 |
// finish up
|
|
| 315 | 315 |
if(cl_autodemo.integer && (cl_autodemo_delete.integer & 1)) |
| 316 | 316 |
{
|
| 317 | 317 |
FS_RemoveOnClose(cls.demofile); |
| ... | ... | |
| 378 | 378 | |
| 379 | 379 |
// open the demo file |
| 380 | 380 |
Con_Printf("recording to %s.\n", name);
|
| 381 |
|
|
| 381 | 382 |
cls.demofile = FS_OpenRealFile(name, "wb", false); |
| 382 | 383 |
if (!cls.demofile) |
| 383 | 384 |
{
|
| ... | ... | |
| 388 | 389 | |
| 389 | 390 |
cls.forcetrack = track; |
| 390 | 391 |
FS_Printf(cls.demofile, "%i\n", cls.forcetrack); |
| 391 | ||
| 392 |
|
|
| 392 | 393 |
cls.demorecording = true; |
| 393 | 394 |
cls.demo_lastcsprogssize = -1; |
| 394 | 395 |
cls.demo_lastcsprogscrc = -1; |
| ... | ... | |
| 414 | 415 |
Con_Print("play <demoname> : plays a demo\n");
|
| 415 | 416 |
return; |
| 416 | 417 |
} |
| 417 | ||
| 418 |
|
|
| 419 |
Con_Printf("Requested demo %s.\n", name);
|
|
| 420 |
|
|
| 418 | 421 |
// open the demo file |
| 419 | 422 |
strlcpy (name, Cmd_Argv(1), sizeof (name)); |
| 420 | 423 |
FS_DefaultExtension (name, ".dem", sizeof (name)); |
| ... | ... | |
| 610 | 613 |
cls.td_frames = -2; // skip the first frame |
| 611 | 614 |
cls.demonum = -1; // stop demo loop |
| 612 | 615 |
} |
| 613 | ||
| 614 | 616 |
Modified clvm_cmds.c |
| clvm_cmds.c | ||
|---|---|---|
| 4983 | 4983 |
VM_digest_hex, // #639 |
| 4984 | 4984 |
VM_CL_V_CalcRefdef, // #640 void(entity e) V_CalcRefdef (DP_CSQC_V_CALCREFDEF) |
| 4985 | 4985 |
NULL, // #641 |
| 4986 |
VM_rename, // #642 float(string from, string to, float overwrite) rename |
|
| 4987 |
NULL |
|
| 4986 | 4988 |
}; |
| 4987 | 4989 | |
| 4988 | 4990 |
const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t); |
| 4989 | 4991 |
Modified dpdefs/csprogsdefs.qc |
| dpdefs/csprogsdefs.qc | ||
|---|---|---|
| 435 | 435 |
string(string s) strzone = #118; |
| 436 | 436 |
void(string s) strunzone = #119; |
| 437 | 437 | |
| 438 |
// Colin |
|
| 439 |
float(string from, string to, float overwrite) rename = #643; |
|
| 440 | ||
| 438 | 441 |
// FTEQW range #200-#299 |
| 439 | 442 | |
| 440 | 443 |
float(float number, float quantity) bitshift = #218; |
| 441 | 444 |
Modified dpdefs/dpextensions.qc |
| dpdefs/dpextensions.qc | ||
|---|---|---|
| 2115 | 2115 |
vector(string s) stov = #117; // returns vector value from a string |
| 2116 | 2116 |
string(string s, ...) strzone = #118; // makes a copy of a string into the string zone and returns it, this is often used to keep around a tempstring for longer periods of time (tempstrings are replaced often) |
| 2117 | 2117 |
void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!) |
| 2118 | ||
| 2119 |
// Colin |
|
| 2120 |
float(string from, string to, float overwrite) rename = #643; |
|
| 2121 | ||
| 2118 | 2122 |
//constants: |
| 2119 | 2123 |
float FILE_READ = 0; |
| 2120 | 2124 |
float FILE_APPEND = 1; |
| 2121 | 2125 |
Modified dpdefs/menudefs.qc |
| dpdefs/menudefs.qc | ||
|---|---|---|
| 244 | 244 |
string fgets(float fhandle) = #50; |
| 245 | 245 |
void fputs(float fhandle, string s) = #51; |
| 246 | 246 | |
| 247 |
// Colin |
|
| 248 |
float rename(string from, string to, float overwrite) = #643; |
|
| 249 | ||
| 247 | 250 |
float strlen(string s) = #52; |
| 248 | 251 |
string strcat(string s1,string s2,...) = #53; |
| 249 | 252 |
string substring(string s, float start, float length) = #54; |
| 250 | 253 |
Modified fs.c |
| fs.c | ||
|---|---|---|
| 72 | 72 |
# define read _read |
| 73 | 73 |
# define write _write |
| 74 | 74 |
# define close _close |
| 75 |
// Colin |
|
| 76 |
# define link _link |
|
| 75 | 77 |
# define unlink _unlink |
| 76 | 78 |
# define dup _dup |
| 77 | 79 |
#endif |
| ... | ... | |
| 1923 | 1925 | |
| 1924 | 1926 |
// -basedir <path> |
| 1925 | 1927 |
// Overrides the system supplied base directory (under GAMENAME) |
| 1926 |
// COMMANDLINEOPTION: Filesystem: -basedir <path> chooses what base directory the game data is in, inside this there should be a data directory for the game (for example id1) |
|
| 1928 |
// COMMANDLINEOPTION: Filesystem: -basedir <path> chooses what |
|
| 1929 |
// base directory the game data is in, inside this there should be a data |
|
| 1930 |
// directory for the game (for example id1) |
|
| 1927 | 1931 |
i = COM_CheckParm ("-basedir");
|
| 1928 | 1932 |
if (i && i < com_argc-1) |
| 1929 | 1933 |
{
|
| ... | ... | |
| 1938 | 1942 |
#ifdef DP_FS_BASEDIR |
| 1939 | 1943 |
strlcpy(fs_basedir, DP_FS_BASEDIR, sizeof(fs_basedir)); |
| 1940 | 1944 |
#elif defined(MACOSX) |
| 1941 |
// FIXME: is there a better way to find the directory outside the .app, without using Objective-C? |
|
| 1945 |
// FIXME: is there a better way to find the directory |
|
| 1946 |
// outside the .app, without using Objective-C? |
|
| 1942 | 1947 |
if (strstr(com_argv[0], ".app/")) |
| 1943 | 1948 |
{
|
| 1944 | 1949 |
char *split; |
| ... | ... | |
| 2611 | 2616 |
return FS_SysOpen (real_path, mode, false); |
| 2612 | 2617 |
} |
| 2613 | 2618 | |
| 2619 |
/* |
|
| 2620 |
==================== |
|
| 2621 |
FS_RenameFile |
|
| 2622 | ||
| 2623 |
The *not* syntax is the same as rename: a boolean is required to |
|
| 2624 |
determine if a file should be overwritten |
|
| 2625 |
Used for renaming files like the .dem files. |
|
| 2626 |
==================== */ |
|
| 2627 |
int FS_RenameFile(const char *oldname, const char *newname, qboolean overwrite) |
|
| 2628 |
{
|
|
| 2629 |
// Hold the buffersize of real_path_old and real_path_new, |
|
| 2630 |
// respectively. |
|
| 2631 |
size_t bufsize_old = strlen(fs_gamedir) + strlen(oldname) + 2; |
|
| 2632 |
size_t bufsize_new = strlen(fs_gamedir) + strlen(newname) + 2; |
|
| 2633 |
|
|
| 2634 |
// Hold the real path to the old and new file, respectively. |
|
| 2635 |
char real_path_old[bufsize_old]; |
|
| 2636 |
char real_path_new[bufsize_new]; |
|
| 2637 |
|
|
| 2638 |
int error; |
|
| 2639 |
|
|
| 2640 |
// Nul terminate. |
|
| 2641 |
real_path_old[0] = '\0'; |
|
| 2642 |
real_path_new[0] = '\0'; |
|
| 2643 |
|
|
| 2644 |
// First check if the filename will be nasty |
|
| 2645 |
if (FS_CheckNastyPath(oldname, false) || FS_CheckNastyPath(newname, false)) |
|
| 2646 |
{
|
|
| 2647 |
Con_Printf("FS_RenameFile: nasty filename rejected\n");
|
|
| 2648 |
return -1; |
|
| 2649 |
} |
|
| 2650 |
|
|
| 2651 |
// Allocate the game path |
|
| 2652 |
strlcat(real_path_old, fs_gamedir, sizeof(real_path_old)); |
|
| 2653 |
strlcat(real_path_new, fs_gamedir, sizeof(real_path_new)); |
|
| 2654 |
|
|
| 2655 |
// Allocate the old and new name |
|
| 2656 |
strlcat(real_path_old, oldname, sizeof(real_path_old)); |
|
| 2657 |
strlcat(real_path_new, newname, sizeof(real_path_new)); |
|
| 2658 |
|
|
| 2659 |
real_path_old[strlen(real_path_old)] = '\0'; |
|
| 2660 |
real_path_new[strlen(real_path_new)] = '\0'; |
|
| 2661 |
|
|
| 2662 |
Con_Printf("old path: %s\n", real_path_old);
|
|
| 2663 |
Con_Printf("new path: %s\n", real_path_new);
|
|
| 2664 |
|
|
| 2665 |
// Check if new name already exists IF overwrite is not set |
|
| 2666 |
if(!overwrite && FS_FileExists(newname)) {
|
|
| 2667 |
Con_Printf("FS_RenameFile: the newname already exists\n");
|
|
| 2668 |
return -1; |
|
| 2669 |
} |
|
| 2670 | ||
| 2671 |
// Rename the file and check for errors |
|
| 2672 |
error = rename(real_path_old, real_path_new); |
|
| 2673 |
if(error < 0) |
|
| 2674 |
{
|
|
| 2675 |
Con_Printf("FS_RenameFile: rename operation failed with error: %i\n", error);
|
|
| 2676 |
return -1; |
|
| 2677 |
} |
|
| 2678 |
|
|
| 2679 |
return 0; |
|
| 2680 |
} |
|
| 2614 | 2681 | |
| 2615 | 2682 |
/* |
| 2616 | 2683 |
==================== |
| 2617 | 2684 |
Modified fs.h |
| fs.h | ||
|---|---|---|
| 62 | 62 |
int FS_SysOpenFD(const char *filepath, const char *mode, qboolean nonblocking); // uses absolute path |
| 63 | 63 |
qfile_t* FS_SysOpen (const char* filepath, const char* mode, qboolean nonblocking); // uses absolute path |
| 64 | 64 |
qfile_t* FS_OpenRealFile (const char* filepath, const char* mode, qboolean quiet); |
| 65 | ||
| 66 |
// Colin: |
|
| 67 |
int FS_RenameFile(const char *oldname, const char *newname, qboolean overwrite); |
|
| 65 | 68 |
qfile_t* FS_OpenVirtualFile (const char* filepath, qboolean quiet); |
| 66 | 69 |
qfile_t* FS_FileFromData (const unsigned char *data, const size_t size, qboolean quiet); |
| 67 | 70 |
int FS_Close (qfile_t* file); |
| 68 | 71 |
Modified mvm_cmds.c |
| mvm_cmds.c | ||
|---|---|---|
| 1542 | 1542 |
VM_digest_hex, // #639 |
| 1543 | 1543 |
NULL, // #640 |
| 1544 | 1544 |
VM_M_crypto_getmyidstatus, // #641 float(float i) crypto_getmyidstatus |
| 1545 |
VM_rename, // #642 float(string from, string to, float overwrite) rename |
|
| 1545 | 1546 |
NULL |
| 1546 | 1547 |
}; |
| 1547 | 1548 | |
| 1548 | 1549 |
Modified prvm_cmds.c |
| prvm_cmds.c | ||
|---|---|---|
| 2002 | 2002 |
PRVM_ED_Write (prog, file, ent); |
| 2003 | 2003 |
} |
| 2004 | 2004 | |
| 2005 |
/* |
|
| 2006 |
========= |
|
| 2007 |
VM_rename |
|
| 2008 | ||
| 2009 |
rename(string from, string to, float overwrite) |
|
| 2010 |
========= |
|
| 2011 |
*/ |
|
| 2012 |
void VM_rename(prvm_prog_t *prog) |
|
| 2013 |
{
|
|
| 2014 |
const char* oldname; |
|
| 2015 |
const char* newname; |
|
| 2016 |
int error; |
|
| 2017 |
qboolean overwrite; |
|
| 2018 |
|
|
| 2019 |
// |
|
| 2020 |
VM_SAFEPARMCOUNT(3, VM_rename); |
|
| 2021 | ||
| 2022 |
oldname = PRVM_G_STRING(OFS_PARM0); |
|
| 2023 |
newname = PRVM_G_STRING(OFS_PARM1); |
|
| 2024 |
overwrite = (PRVM_G_FLOAT(OFS_PARM2) != 0); |
|
| 2025 |
|
|
| 2026 |
error = FS_RenameFile(oldname, newname, overwrite); |
|
| 2027 |
|
|
| 2028 |
if(error < 0){
|
|
| 2029 |
VM_Warning(prog, "rename: could not rename file\n"); |
|
| 2030 |
PRVM_G_FLOAT(OFS_RETURN) = -1.0; |
|
| 2031 |
} |
|
| 2032 |
|
|
| 2033 |
PRVM_G_FLOAT(OFS_RETURN) = 1.0; |
|
| 2034 |
} |
|
| 2035 | ||
| 2036 | ||
| 2005 | 2037 |
// KrimZon - DP_QC_ENTITYDATA |
| 2006 | 2038 |
/* |
| 2007 | 2039 |
========= |
| 2008 | 2040 |
Modified prvm_cmds.h |
| prvm_cmds.h | ||
|---|---|---|
| 299 | 299 |
void VM_fputs(prvm_prog_t *prog); |
| 300 | 300 |
void VM_writetofile(prvm_prog_t *prog); // only used by menu |
| 301 | 301 | |
| 302 |
// Colin: |
|
| 303 |
void VM_rename(prvm_prog_t *prog); |
|
| 304 | ||
| 305 | ||
| 302 | 306 |
void VM_strlen(prvm_prog_t *prog); |
| 303 | 307 |
void VM_strcat(prvm_prog_t *prog); |
| 304 | 308 |
void VM_substring(prvm_prog_t *prog); |
| 305 | 309 |
Modified svvm_cmds.c |
| svvm_cmds.c | ||
|---|---|---|
| 3826 | 3826 |
NULL, // #638 |
| 3827 | 3827 |
VM_digest_hex, // #639 |
| 3828 | 3828 |
NULL, // #640 |
| 3829 |
NULL, // #641 |
|
| 3830 |
VM_rename, // #642 float(string from, string to) rename |
|
| 3831 |
NULL |
|
| 3829 | 3832 |
}; |
| 3830 | 3833 | |
| 3831 | 3834 |
const int vm_sv_numbuiltins = sizeof(vm_sv_builtins) / sizeof(prvm_builtin_t); |