Ejemplo n.º 1
0
Archivo: 2002.php Proyecto: rwruss/ib3
echo 'City Data: ';
print_r($cityDat);
if ($cityDat[11] > 0) {
    // Load resource Data
    $slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
    $cityRsc = array_fill(1, 100, 0);
    $rscDat = unpack("i*", readSlotData($slotFile, $cityDat[11], 40));
    $numHave = sizeof($rscDat) / 2;
    echo '<p>City Resources in slot ' . $cityDat[11] . ': ';
    for ($i = 1; $i < $numHave; $i++) {
        $cityRsc[$rscDat[$i * 2 - 1]] = $rscDat[$i * 2];
    }
    // Update for resources to add...
    $cityRsc[$postVals[1]] += $postVals[2];
    // clear out empties
    $writeRsc = array_filter($cityRsc);
    $writeDat = '';
    foreach ($writeRsc as $rscID => $rscAmt) {
        $writeDat .= pack('i*', $rscID, $rscAmt);
        echo 'Save rsc ' . $rscID . '<br>';
    }
    print_r($writeRsc);
    writeBlocktoSlot($gamePath . '/gameSlots.slt', $cityDat[11], $writeDat, $slotFile, 40);
    //writeBlocktoSlot($slotHandle, $checkSlot, $addData, $slotFile, $slotSize)
    echo '<p>Pack check:<br>
		size: ' . strlen($writeDat) . '<br>';
    print_r(unpack('i*', $writeDat));
} else {
    echo 'Resource slot error';
}
fclose($slotFile);
Ejemplo n.º 2
0
function newTown($id, $townFile, $slotFile, $townDtls)
{
    global $defaultBlockSize, $gameSlot, $pGameID, $startLocation, $gamePath;
    $townData = array_fill(1, 100, 0);
    $townData[1] = $townDtls[0];
    // X loc
    $townData[2] = $townDtls[1];
    // Y Loc
    $townData[3] = 1;
    $townData[4] = 1;
    $townData[5] = $townDtls[2];
    // pgameId
    $townData[6] = $townDtls[2];
    // pgameID
    $townData[7] = 1;
    $townData[8] = $townDtls[3];
    // Culture
    $townData[25] = $townDtls[4];
    // Culture
    $townData[27] = time();
    // Create a credential list for the town and record this player as having full cred.
    $credListSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    $townData[19] = $credListSlot;
    echo 'credintial slot:' . $credListSlot . '<br>';
    writeBlocktoSlot($gamePath . "/gameSlots.slt", $credListSlot, pack('i*', -9, $pGameID), $slotFile, 40);
    // ($slotHandle, $checkSlot, $addData, $slotFile, $slotSize)
    // Make a chars slot for the new town and record the player's faction leader as the town's leader
    $townCharSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    echo 'Town Char Slot is ' . $townCharSlot . '<br>';
    $townData[13] = $townCharSlot;
    // Make a units slot for the new town
    $townUnitSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    echo 'Town Unit Slot is ' . $townUnitSlot . '<br>';
    $townData[18] = $townUnitSlot;
    // Make a resource slot for the new town
    $rscSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    echo 'Town RSC Slot is ' . $rscSlot . '<br>';
    $townData[11] = $rscSlot;
    // Make a task slot for the new town
    $taskSlot = startASlot($slotFile, $gamePath . "/gameSlots.slt");
    echo 'Town task Slot is ' . $taskSlot . '<br>';
    $townData[21] = $taskSlot;
    echo 'Final town data:';
    print_r($townData);
    echo '<p>';
    fseek($townFile, $id * $defaultBlockSize);
    for ($i = 1; $i <= sizeof($townData); $i++) {
        fwrite($townFile, pack('i', $townData[$i]));
    }
    return $townData;
}
Ejemplo n.º 3
0
Archivo: 1004.php Proyecto: rwruss/ib3
 $newPlayer->unitDat[19] = $charSlot;
 // Record the char slot
 $newPlayer->unitDat[11] = $townID;
 // Primary City
 $newPlayer->saveAll($unitFile);
 // Set settlment Data as applicable
 // get new index for next unit
 // Add char data to the town character slot
 if ($startTown) {
     $dat = pack('i*', -9, $newCharID);
     fseek($gameSlot, $townData[13] * 40 + 4);
     fwrite($gameSlot, $dat);
 }
 // Record leadership of the town in the character's position information
 $newDat = pack('i*', -1 * $townID, 10);
 writeBlocktoSlot($gamePath . '/gameSlots.slt', $positionSlot, $newDat, $gameSlot, 40);
 // writeBlocktoSlot($slotHandle, $checkSlot, $addData, $slotFile, $slotSize)
 // Create units based on the following unit IDs
 $unitInf = explode("<->", file_get_contents($scnPath . '/units.desc'));
 $makeTypes = [1, 2];
 for ($i = 0; $i < sizeof($makeTypes); $i++) {
     $newId = $unitIndex;
     $unitIndex += 4;
     echo 'Make unit type ' . $makeTypes[$i] . ' at unit #' . $newId . '<br>';
     $thisDtl = explode('<-->', $unitInf[$makeTypes[$i]]);
     $typeParams = explode(",", $thisDtl[1]);
     fseek($unitFile, $newId * $defaultBlockSize + $unitBlockSize - 4);
     fwrite($unitFile, pack("i", 0));
     $newUnit = new unit($newId, [], $unitFile);
     $newUnit->unitDat[1] = $startLocation[0];
     // X Loc