HomeNewsFeaturesLicensingDownloadsScreenshotsFAQRoadmap Contact Us
Search:
1 Online

Community

Discussion Topics Recent Postings User Contributions General Articles Example Documentation Credits

Licensed Developer

Programmer's Manual Artists Manual Tutorials and Articles

Programming: Game Code

Game Code Overview Server Side Game Code Client Side Game Code

Programming: System

Alphabetical Function List Renderer File System Collision & Ray Casting Low Level Audio Game Audio The Console Console Variable List Multiplayer Localisation Maths Library Memory Manager Model File Formats Texture Formats

Art: Overviews

Specifications Shaders Particle Systems Lens Flares Cipher console Cipher file types Tutorials Reference

Art: Tools

Shader Designer Particle Designer 3dsmax tools Model Conversion Font Generator

Cipher Engine
Game Development Search Engine
GameDev.net
You are not signed in - [sign in] [register]

Sample Documents


Sample From Programmer's Manual


int fs_Open(const tchar_t* filename,
int mode,
filehandle_t* hfile);

Opens a file for reading or writing

ParameterDescription
filename The name of the file to open, relative to the game folder.
mode FS_READ to open for reading, FS_WRITE or FS_APPEND for writing.
hfile The address of a file handle that will be returned to the caller.

Returns

Returns the size of the file, in bytes. If the file can not be opened fs_Open will return zero, though it is also possible to get this value by successfully opening a zero length file. You should check hfile!=0 to test if the open was successful. If mode was FS_WRITE, fs_Open always returns zero.

Remarks

filename is always case sensitive, even if the host OS has less strict rules. The path separator character is always forward slash (/), even if the host OS has a different convention. Cipher will perform the appropriate translations. Typically you will be reading from compressed pak files though, which are completely under Cipher's control and are not effected by the host OS.

FS_READ opens the file for reading, leaving the original file unchanged. It will first try and open the file on the host filesystem if supported. If that fails it will look in the pak files in alphabetical order to try and find the file. fs_ReadBytes can be called on a file opened in this mode.

FS_WRITE opens the file on the host filesystem for writing, erasing any file that was previously there. It will not replace a version of the file that resides inside a pak file. fs_WriteBytes can be called on a file opened in this mode.

FS_APPEND opens the file on the host filesystem for writing. If the file already exists, Cipher will first seek to the end of the file. fs_WriteBytes can be called on a file opened in this mode.

Not all platforms have a file system that supports writing, so care should be taken when using FS_WRITE and FS_APPEND. FS_WRITE and FS_APPEND are also unable to open files that end .pak to prevent them from destroying the games pak files.

Since Cipher does not permit '..' in filenames, it is not possible to open any files above the game folder using this interface. This is to provide security for the MOD community.

On returning, hfile will be zero if the file could not be opened. Any non-zero value is a valid handle.

Example

// A simple example that opens a file
// and reads all its contents into a buffer
filehandle_t hfile;
int filesize;

// try and open the file
filesize = fs_Open(_T("Data.dat"), FS_READ, &hfile);

// if it did not open, fail
if (hfile==0)
	return rfalse;

// read in all the bytes and close the file
fs_ReadBytes(bigBuffer, filesize, hfile);
fs_Close(hfile);

See Also

fs_Close, fs_ReadBytes, fs_WriteBytes, fs_FindFiles



Sample From Artist's Manual (Shader Designer)


Navigating the Interface


Menu Bar - Access to all of the Shader Designer Menus
(See also: File Menu, Edit Menu, Actions Menu, Preview Menu, View Menu, Help Menu.)


Toolbar - Shortcut buttons to Shader Designer's commonly used features.
(See also: Toolbar)


Shader Tree - Displays a hierarchical list of all of the shaders in the current open .sdr Shader File. The Shader Tree can be expanded and collapsed similar to Folders within the Windows Explorer.

Shader.
This is an entire shader that will be used to replace a texture of the same name in the current Cipher Project.

Pass.
Passes form the framework of a Shader, similar to layers in a 2D painting package like Photoshop. Pass 1 will be rendered first, then Pass 2 will be rendered and blended over Pass 1 and so on up to Pass 8. Each Pass can have a different texture, different blending modes, different vertex colours and different texture manipulation commands.

Command.
Commands contain all of the interactive settings that make up the Shader. Commands that are associated directly to a shader are known as Global Commands and affect the entire shader e.g. in the shader tree shown above, the 'State: Sort' command. Commands that are associated to a specific pass are known as Pass Commands and affect only that pass e.g. in the shader tree shown above, the 'Blend Function: Blend' command.

(See also: Edit Menu, Actions Menu)


Data Panel - Displays the settings available for the currently selected element of the Shader Tree. Settings changed in the Data Panel will be automatically updated on the preview model in the Preview window.


Preview - Displays the realtime 3D preview using the currently selected model and shader. A right-click menu is available in the Preview window for access to commonly used camera and model controls.
(See also: Preview Menu)


Animation controls - If the preview model contains an animated skeleton or vertex animation, this panel is displayed. It displays controls for changing the preview segment and playback speed of animations.
(See also: Animation controls)


Status Bar - Reports a quick reference guide for the currently highlighted menu entry or Toolbar button.