BGC Massmod

From Soldat Community Wiki
Revision as of 22:57, 23 August 2012 by Shoozza (talk | contribs) (Created page with "<source lang="C"> #include <iostream> #include <string> #include <algorithm> #include <fstream> #include <iterator> #include <vector> #include <stdio.h> #include <stdlib.h> ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <iterator>
#include <vector>

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

using namespace std;

int main(int argc, char *argv[]){

    WIN32_FIND_DATA findFileData;

    HANDLE hFind = FindFirstFile("*.pms", &findFileData);
    if(hFind  == INVALID_HANDLE_VALUE){
        cout << "No *.PMS files found" << endl;
        cout << "* make sure you place the application in soldat/maps/ folder" << endl;
        FindClose(hFind);
        return 1;
    }else{
        cout << "Starting..." << endl;
    }

    if(argc != 7){
        cout << "Usage: RED GREEN BLUE RED GREEN BLUE" << endl
        << " values in DEC (0-255), first set top, then bottom" << endl;
        return 1;
    }

    int filec = 1;
    fstream file;
    int length;
    char *buffer;

    while(FindNextFile(hFind, &findFileData)){
        cout << filec << ". " << findFileData.cFileName << "... " << flush;
        // get contents
        file.open(findFileData.cFileName, ios_base:: in | ios_base::binary);
        file.seekg (0, ios::end);
        length = file.tellg();
        file.seekg (0, ios::beg);
        buffer = new char [length];
        file.read (buffer,length);
        file.close();
        //modify contents
        // top color
        buffer[68] = atoi(argv[3]); // B
        buffer[69] = atoi(argv[2]); // G
        buffer[70] = atoi(argv[1]); // R
        buffer[71] = 0;  // A
        // bottom color
        buffer[72] = atoi(argv[6]); // B
        buffer[73] = atoi(argv[5]); // G
        buffer[74] = atoi(argv[4]); // R
        buffer[75] = 0;  // A
        //overwrite with new contents
        file.open(findFileData.cFileName, ios_base::out | ios_base::binary | ios_base::trunc);
        file.write (buffer,length);
        file.close();

        delete[] buffer;

        cout << "Ok!" << endl;
        filec++;
    }

    FindClose(hFind);
    return 0;
}

PHP PMS Background colors mass modifier

<?php

$files = array_merge(glob("*.PMS"), glob("*.pms"));;

// these are ctf_Steel's colors, 
// note: alpha is useless
// C = unsigned char---  B   R   G  A
$new_top = pack("CCCC", 74, 63, 74, 0); // top 
$new_bot = pack("CCCC", 39, 39, 22, 0); // bottom

echo "Found " . count($files) . " file(s) - processing...\n\n";

$i = 1;

foreach($files as $file){
	echo $i . ". " . $file . " ... ";
	$contents = file_get_contents($file, FILE_BINARY);
	// replace that 
	$mod = substr_replace($contents, $new_top, 4+1+38+1+24, 4);
	$mod = substr_replace($mod, $new_bot, 4+1+38+1+24+4, 4);
	// overwrite
	file_put_contents($file, $mod);
	echo " ... OK!\n";
	$i++;
}

?>